Skip to content

Commit

Permalink
Merge 8bfe904 into 5088cb3
Browse files Browse the repository at this point in the history
  • Loading branch information
Mackilem committed May 23, 2019
2 parents 5088cb3 + 8bfe904 commit 1b43237
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions br_purchase/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'data': [
'views/purchase_view.xml',
'views/account_invoice.xml',
'views/res_partner.xml',
],
'installable': True,
'auto_install': True
Expand Down
1 change: 1 addition & 0 deletions br_purchase/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
from . import purchase
from . import account_invoice
from . import stock
from . import res_partner
6 changes: 6 additions & 0 deletions br_purchase/models/purchase.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ def _compute_tax_id(self):
for order in self:
order.order_line._compute_tax_id()

@api.onchange('partner_id')
def onchange_partner_fpos(self):
if not self.fiscal_position_id:
fpos = self.partner_id.property_purchase_fiscal_position_id
self.fiscal_position_id = fpos.id


class PurchaseOrderLine(models.Model):
_inherit = 'purchase.order.line'
Expand Down
15 changes: 15 additions & 0 deletions br_purchase/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# © 2019 Mackilem Van der Laan, Trustcode
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class ResPartner(models.Model):
_inherit = 'res.partner'

property_purchase_fiscal_position_id = fields.Many2one(
string="Purchase Fiscal Position",
comodel_name="account.fiscal.position",
domain="[('fiscal_type', '=', 'entrada')]",
company_dependent=True,
ondelete="set null")
13 changes: 13 additions & 0 deletions br_purchase/views/res_partner.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="br_purchase_res_partner_form" model="ir.ui.view">
<field name="name">br.purchase.res.partner.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="account.view_partner_property_form"/>
<field name="arch" type="xml">
<field name="property_account_position_id" position="after">
<field name="property_purchase_fiscal_position_id" />
</field>
</field>
</record>
</odoo>

0 comments on commit 1b43237

Please sign in to comment.