Skip to content

Commit

Permalink
[IMP] l10n_br_account_withholding: handling of partner_id assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
kaynnan committed Jul 15, 2024
1 parent 0ea78da commit a39bdc5
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
1 change: 1 addition & 0 deletions l10n_br_account_withholding/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"l10n_br_account",
],
"data": [
"views/res_city.xml",
"views/l10n_br_fiscal_tax_group.xml",
"views/account_move.xml",
],
Expand Down
1 change: 1 addition & 0 deletions l10n_br_account_withholding/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import account_move
from . import l10n_br_fiscal_tax_group
from . import account_move_line
from . import res_city
12 changes: 11 additions & 1 deletion l10n_br_account_withholding/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,18 @@ def _prepare_wh_invoice(self, move_line, fiscal_group):
"""
wh_date_invoice = move_line.move_id.date
wh_due_invoice = wh_date_invoice.replace(day=fiscal_group.wh_due_day)

city_id = (
self.invoice_line_ids[0].issqn_fg_city_id
if self.invoice_line_ids[0].issqn_fg_city_id
else self.partner_id.city_id
)
partner_id = (
city_id.partner_wh_id if city_id.partner_wh_id else fiscal_group.partner_id
)

values = {
"partner_id": fiscal_group.partner_id.id,
"partner_id": partner_id,
"date": wh_date_invoice,
"invoice_date": wh_date_invoice,
"invoice_date_due": wh_due_invoice + relativedelta(months=1),
Expand Down
14 changes: 14 additions & 0 deletions l10n_br_account_withholding/models/res_city.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2024 - TODAY, Kaynnan Lemes <kaynnan.lemes@escodoo.com.br>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResCity(models.Model):

_inherit = "res.city"

partner_wh_id = fields.Many2one(
comodel_name="res.partner",
string="WH Partner",
)
15 changes: 15 additions & 0 deletions l10n_br_account_withholding/views/res_city.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 - TODAY, Kaynnan Lemes <kaynnan.lemes@escodoo.com.br>
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="res_city_tree_view" model="ir.ui.view">
<field name="name">res.city.tree</field>
<field name="model">res.city</field>
<field name="inherit_id" ref="base_address_city.view_city_tree" />
<field name="arch" type="xml">
<xpath expr="//field[@name='state_id']" position="after">
<field name="partner_wh_id" />
</xpath>
</field>
</record>
</odoo>

0 comments on commit a39bdc5

Please sign in to comment.