Skip to content

Commit

Permalink
ss[MIG] account_payment_multi_deduction: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TITUS6304658 committed Jun 19, 2023
1 parent 485aec5 commit 5cd9815
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 76 deletions.
2 changes: 1 addition & 1 deletion account_payment_multi_deduction/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Payment Register with Multiple Deduction",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"author": "Ecosoft, Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/account-payment",
Expand Down
14 changes: 12 additions & 2 deletions account_payment_multi_deduction/wizard/account_payment_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ def _compute_default_analytic(self):
active_ids = self.env.context.get("active_ids")
moves = self.env["account.move"].browse(active_ids)
move_lines = moves.mapped("line_ids")
analytic_account = move_lines.mapped("analytic_account_id")
analytic_account = (
move_lines.mapped("analytic_account_id")
if "analytic_account_id" in move_lines._fields
else self.env["account.analytic.account"]
)

analytic_tag = move_lines.mapped("analytic_tag_ids")
taxes_account = (
self.env["account.tax.repartition.line"]
Expand All @@ -71,7 +76,12 @@ def _compute_default_analytic(self):

def _update_vals_deduction(self, moves):
move_lines = moves.mapped("line_ids")
analytic_account = move_lines.mapped("analytic_account_id")
analytic_account = (
move_lines.mapped("analytic_account_id")
if "analytic_account_id" in move_lines._fields
else self.env["account.analytic.account"]
)

analytic_tag = move_lines.mapped("analytic_tag_ids")
taxes_account = (
self.env["account.tax.repartition.line"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,83 +3,82 @@
<field name="name">account.payment.register.form</field>
<field name="model">account.payment.register</field>
<field name="inherit_id" ref="account.view_account_payment_register_form" />
<field name="groups_id" eval="[(4, ref('account.group_account_invoice'))]" />
<field name="arch" type="xml">
<xpath expr="//field[@name='writeoff_account_id']" position="after">
<div
attrs="{'invisible': [('payment_difference_handling', '!=', 'reconcile')]}"
>
<label
for="writeoff_analytic_account_id"
class="oe_edit_only"
groups="analytic.group_analytic_accounting"
/>
<field
name="writeoff_analytic_account_id"
<data>
<xpath expr="//field[@name='writeoff_account_id']" position="after">
<div
attrs="{'invisible': [('payment_difference_handling', '!=', 'reconcile')]}"
groups="analytic.group_analytic_accounting"
/>
<label
for="writeoff_analytic_tag_ids"
class="oe_edit_only"
groups="analytic.group_analytic_tags"
/>
<field
name="writeoff_analytic_tag_ids"
groups="analytic.group_analytic_tags"
widget="many2many_tags"
/>
</div>
</xpath>
<xpath
expr="/form/group/group[@name='group3']/div/div"
position="attributes"
>
<attribute
name="attrs"
>{'invisible': [('payment_difference_handling','!=','reconcile')]}</attribute>
</xpath>
<xpath expr="/form/group/group[@name='group3']" position="after">
<group
colspan="4"
attrs="{'invisible': [('payment_difference_handling', '!=', 'reconcile_multi_deduct')]}"
>
<label
for="writeoff_analytic_account_id"
class="oe_edit_only"
groups="analytic.group_analytic_accounting"
/>
<field
name="writeoff_analytic_account_id"
groups="analytic.group_analytic_accounting"
/>
<label
for="writeoff_analytic_tag_ids"
class="oe_edit_only"
groups="analytic.group_analytic_tags"
/>
<field
name="writeoff_analytic_tag_ids"
groups="analytic.group_analytic_tags"
widget="many2many_tags"
/>
</div>
</xpath>
<xpath
expr="/form/group/group[@name='group3']/div/div"
position="attributes"
>
<field name="deduct_residual" invisible="1" />
<field name="deduct_analytic_account_id" invisible="1" />
<field name="deduct_analytic_tag_ids" invisible="1" />
<field
name="deduction_ids"
nolabel="1"
colspan="2"
context="{
'default_amount': deduct_residual,
'default_analytic_account_id': deduct_analytic_account_id,
'default_analytic_tag_ids': deduct_analytic_tag_ids
}"
<attribute
name="attrs"
>{'invisible': [('payment_difference_handling','!=','reconcile')]}</attribute>
</xpath>
<xpath expr="/form/group/group[@name='group3']" position="after">
<group
colspan="4"
attrs="{'invisible': [('payment_difference_handling', '!=', 'reconcile_multi_deduct')]}"
groups="base.group_user"
>
<tree editable="bottom">
<field name="currency_id" invisible="1" />
<field name="open" />
<field
name="account_id"
attrs="{'required': [('open', '=', False)]}"
/>
<field
name="analytic_account_id"
optional="show"
groups="analytic.group_analytic_accounting"
/>
<field
name="analytic_tag_ids"
widget="many2many_tags"
optional="show"
groups="analytic.group_analytic_tags"
/>
<field name="name" />
<field name="amount" sum="Total Deduction" />
</tree>
</field>
</group>
</xpath>
<field name="deduct_residual" invisible="1" />
<field name="deduct_analytic_account_id" invisible="1" />
<field name="deduct_analytic_tag_ids" invisible="1" />
<field
name="deduction_ids"
nolabel="1"
colspan="2"
context="{'default_amount': deduct_residual, 'default_analytic_account_id': deduct_analytic_account_id, 'default_analytic_tag_ids': deduct_analytic_tag_ids}"
>
<tree editable="bottom">
<field name="currency_id" invisible="1" />
<field name="open" />
<field
name="account_id"
attrs="{'required': [('open', '=', False)]}"
/>
<field
name="analytic_account_id"
optional="show"
groups="analytic.group_analytic_accounting"
/>
<field
name="analytic_tag_ids"
widget="many2many_tags"
optional="show"
groups="analytic.group_analytic_tags"
/>
<field name="name" />
<field name="amount" sum="Total Deduction" />
</tree>
</field>
</group>
</xpath>
</data>
</field>
</record>
</odoo>

0 comments on commit 5cd9815

Please sign in to comment.