-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ | |
from . import sale_order | ||
from . import stock | ||
from . import account_invoice | ||
from . import purchase_order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2017 Ainara Galdona - Avanzosc S.L. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp import models, fields, api | ||
|
||
|
||
class PurchaseOrder(models.Model): | ||
|
||
_inherit = 'purchase.order' | ||
|
||
req_destination_port = fields.Boolean( | ||
string="Requires destination port", | ||
related="incoterm_id.destination_port") | ||
req_transport_type = fields.Boolean( | ||
string="Requires transport type", | ||
related="incoterm_id.transport_type") | ||
destination_port = fields.Char(string="Destination port") | ||
transport_type = fields.Selection( | ||
[('air', 'Air'), ('maritime', 'Maritime'), ('ground', 'Ground')], | ||
string="Transport type") | ||
|
||
@api.model | ||
def _prepare_invoice(self, order, line_ids): | ||
res = super(PurchaseOrder, self)._prepare_invoice(order, line_ids) | ||
res['incoterm'] = order.incoterm_id.id | ||
res['destination_port'] = order.destination_port | ||
res['transport_type'] = order.transport_type | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<openerp> | ||
<data> | ||
<record id="purchase_order_form" model="ir.ui.view"> | ||
<field name="name">purchase.order.form</field> | ||
<field name="model">purchase.order</field> | ||
<field name="inherit_id" ref="purchase.purchase_order_form"/> | ||
<field name="arch" type="xml"> | ||
<field name="incoterm_id" position="after"> | ||
<field name="req_destination_port" invisible="1"/> | ||
<field name="req_transport_type" invisible="1"/> | ||
<field name="destination_port" attrs="{'required':[('req_destination_port', '=', True)]}"/> | ||
<field name="transport_type" attrs="{'required':[('req_transport_type', '=', True)]}"/> | ||
</field> | ||
</field> | ||
</record> | ||
</data> | ||
</openerp> |