Skip to content

Commit

Permalink
temp rebasing PR 472 (f7f60f6)
Browse files Browse the repository at this point in the history
  • Loading branch information
roboadhoc committed Apr 17, 2024
2 parents 75c95ee + f7f60f6 commit 4b3817a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
10 changes: 5 additions & 5 deletions account_payment_pro/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ class AccountMoveLine(models.Model):
currency_field='company_currency_id',
)

@api.depends_context('matched_payment_id')
@api.depends_context('matched_payment_ids')
def _compute_payment_matched_amount(self):
"""
Reciviendo un matched_payment_id por contexto, decimos en ese payment, cuanto se pago para la lína en cuestión.
"""
matched_payment_id = self._context.get('matched_payment_id', self._context.get('params', {}).get('id'))
matched_payment_ids = self._context.get('matched_payment_ids')

if not matched_payment_id:
if not matched_payment_ids:
self.payment_matched_amount = 0.0
return False
payments = self.env['account.payment'].browse(matched_payment_id)
payment_lines = payments.line_ids.filtered(lambda x: x.account_type in ['asset_receivable', 'liability_payable'])
payments = self.env['account.payment'].search([('id', 'in', matched_payment_ids)])
payment_lines = payments.mapped('line_ids').filtered(lambda x: x.account_type in ['asset_receivable', 'liability_payable'])
for rec in self:
debit_move_amount = sum(payment_lines.mapped('matched_debit_ids').filtered(lambda x: x.debit_move_id == rec).mapped('amount'))
credit_move_amount = sum(payment_lines.mapped('matched_credit_ids').filtered(lambda x: x.credit_move_id == rec).mapped('amount'))
Expand Down
7 changes: 7 additions & 0 deletions account_payment_pro/models/account_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,3 +475,10 @@ def action_post(self):
(counterpart_aml + (rec.to_pay_move_line_ids)).reconcile()

return res

# --- ORM METHODS--- #
def web_read(self, specification):
fields_to_read = list(specification) or ['id']
if 'matched_move_line_ids' in fields_to_read and 'context' in specification['matched_move_line_ids']:
specification['matched_move_line_ids']['context'].update({'matched_payment_ids': self._ids})
return super().web_read(specification)
2 changes: 1 addition & 1 deletion account_payment_pro/security/payment_security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
</data>
</odoo>
</odoo>
2 changes: 1 addition & 1 deletion account_payment_pro/views/account_payment_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
help="Payment will be automatically matched with the oldest lines of this list (by maturity date). You can remove any line you dont want to be matched."/>
</page>
<page string="Paid" invisible="state != 'posted'">
<field name="matched_move_line_ids" context="{'matched_payment_id': id, 'tree_view_ref': 'account_payment_pro.view_move_line_with_matched_tree'}"/>
<field name="matched_move_line_ids" context="{'tree_view_ref': 'account_payment_pro.view_move_line_with_matched_tree'}"/>
</page>
</notebook>
</sheet>
Expand Down
2 changes: 1 addition & 1 deletion account_payment_pro/views/res_company_setting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
</field>
</record>
</data>
</odoo>
</odoo>

0 comments on commit 4b3817a

Please sign in to comment.