sale_down_payment: add a hook that can be used for notifications
This commit is contained in:
@@ -30,3 +30,8 @@ class AccountMoveLine(models.Model):
|
||||
def sale_advance_payement_account_id_change(self):
|
||||
if self.sale_id and self.account_id.user_type_id.type != 'receivable':
|
||||
self.sale_id = False
|
||||
|
||||
def _sale_down_payment_hook(self):
|
||||
# can be used for notifications
|
||||
self.ensure_one()
|
||||
|
||||
|
||||
@@ -25,6 +25,14 @@ class AccountPayment(models.Model):
|
||||
res['sale_id'] = self.sale_id.id
|
||||
return res
|
||||
|
||||
def _create_payment_entry(self, amount):
|
||||
move = super()._create_payment_entry(amount)
|
||||
if hasattr(self, 'sale_id') and self.sale_id:
|
||||
for line in move.line_ids:
|
||||
if line.sale_id and line.account_id.internal_type == 'receivable':
|
||||
line._sale_down_payment_hook()
|
||||
return move
|
||||
|
||||
|
||||
class AccountAbstractPayment(models.AbstractModel):
|
||||
_inherit = "account.abstract.payment"
|
||||
|
||||
@@ -64,7 +64,9 @@ class AccountBankStatementSale(models.TransientModel):
|
||||
self.ensure_one()
|
||||
for line in self.line_ids:
|
||||
if line.move_line_id.sale_id != line.sale_id:
|
||||
line.move_line_id.sale_id = line.sale_id.id
|
||||
line.move_line_id.write({'sale_id': line.sale_id.id or False})
|
||||
if line.sale_id:
|
||||
line.move_line_id._sale_down_payment_hook()
|
||||
|
||||
|
||||
class AccountBankStatementSaleLine(models.TransientModel):
|
||||
|
||||
Reference in New Issue
Block a user