add payable/receiver log for import account.move
This commit is contained in:
parent
8f0d5775a6
commit
5b809b83c4
@ -1,4 +1,6 @@
|
||||
from odoo import models, fields, api
|
||||
import logging
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
class AccountMoveLine(models.Model):
|
||||
_inherit = 'account.move.line'
|
||||
@ -21,3 +23,19 @@ class AccountMoveLine(models.Model):
|
||||
readonly=False,
|
||||
help='Credit journal items that are matched with this journal item.',
|
||||
)
|
||||
@api.constrains('account_id', 'display_type')
|
||||
def _check_payable_receivable(self):
|
||||
for line in self:
|
||||
account_type = line.account_id.account_type
|
||||
if line.move_id.is_sale_document(include_receipts=True):
|
||||
if account_type == 'liability_payable':
|
||||
raise UserError(_("Account %s is of payable type, but is used in a sale operation.", line.account_id.code))
|
||||
if (line.display_type == 'payment_term') ^ (account_type == 'asset_receivable'):
|
||||
_logger.debug("Error receivable on %s: %s - %s (%s)", line.name, line.date_maturity, line.account_id.code, line.account_id.account_type)
|
||||
raise UserError(_("Any journal item on a receivable account must have a due date and vice versa."))
|
||||
if line.move_id.is_purchase_document(include_receipts=True):
|
||||
if account_type == 'asset_receivable':
|
||||
raise UserError(_("Account %s is of receivable type, but is used in a purchase operation.", line.account_id.code))
|
||||
if (line.display_type == 'payment_term') ^ (account_type == 'liability_payable'):
|
||||
_logger.debug("Error payable on %s: %s - %s (%s)", line.date, line.date_maturity, line.account_id.code, line.account_id.account_type)
|
||||
raise UserError(_("Any journal item on a payable account must have a due date and vice versa."))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user