Skip to content

Commit

Permalink
Merge 47b15a9 into d5abf91
Browse files Browse the repository at this point in the history
  • Loading branch information
agaldona committed Jul 13, 2017
2 parents d5abf91 + 47b15a9 commit 319789b
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
6 changes: 4 additions & 2 deletions stock_incoterm_extension/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"version": "8.0.1.0.0",
"license": "AGPL-3",
"depends": ["stock_account",
"sale_stock"],
"sale_stock",
"purchase"],
"author": "OdooMRP team,"
"AvanzOSC,"
"Serv. Tecnol. Avanzados - Pedro M. Baeza",
Expand All @@ -30,7 +31,8 @@
'data': ["security/ir.model.access.csv",
"views/stock_view.xml",
"views/account_invoice_view.xml",
"views/sale_order_view.xml"],
"views/sale_order_view.xml",
"views/purchase_order_view.xml"],
'installable': True,
'auto_install': False,
}
1 change: 1 addition & 0 deletions stock_incoterm_extension/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
from . import sale_order
from . import stock
from . import account_invoice
from . import purchase_order
29 changes: 29 additions & 0 deletions stock_incoterm_extension/models/purchase_order.py
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
18 changes: 18 additions & 0 deletions stock_incoterm_extension/views/purchase_order_view.xml
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>

0 comments on commit 319789b

Please sign in to comment.