mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[FIX] account_credit_control: Do not copy lines credit control lines when partners or accounts are duplicated
This commit is contained in:
committed by
Pedro M. Baeza
parent
d4a4974c45
commit
59cd274f80
@@ -20,6 +20,7 @@
|
||||
##############################################################################
|
||||
from openerp.osv import orm, fields
|
||||
|
||||
|
||||
class AccountAccount(orm.Model):
|
||||
"""Add a link to a credit control policy on account.account"""
|
||||
|
||||
@@ -33,6 +34,15 @@ class AccountAccount(orm.Model):
|
||||
readonly=True),
|
||||
}
|
||||
|
||||
def copy_data(self, cr, uid, id, default=None, context=None):
|
||||
if default is None:
|
||||
default = {}
|
||||
else:
|
||||
default = default.copy()
|
||||
default['credit_control_line_ids'] = False
|
||||
return super(AccountAccount, self).copy_data(
|
||||
cr, uid, id, default=default, context=context)
|
||||
|
||||
|
||||
class AccountInvoice(orm.Model):
|
||||
"""Add a link to a credit control policy on account.account"""
|
||||
@@ -54,24 +64,12 @@ class AccountInvoice(orm.Model):
|
||||
readonly=True),
|
||||
}
|
||||
|
||||
def action_move_create(self, cr, uid, ids, context=None):
|
||||
""" Write the id of the invoice in the generated moves. """
|
||||
if context is None:
|
||||
context = {}
|
||||
# add from_parent_object to the conxtext to let the line.write
|
||||
# call pass through account_constraints
|
||||
ctxt = context.copy()
|
||||
ctxt['from_parent_object'] = True
|
||||
res = super(AccountInvoice, self).action_move_create(cr, uid, ids, context=ctxt)
|
||||
for inv in self.browse(cr, uid, ids, context=ctxt):
|
||||
if inv.move_id:
|
||||
for line in inv.move_id.line_id:
|
||||
line.write({'invoice_id': inv.id}, context=ctxt)
|
||||
return res
|
||||
|
||||
|
||||
class AccountMoveLine(orm.Model):
|
||||
|
||||
_inherit = "account.move.line"
|
||||
|
||||
_columns = {'invoice_id': fields.many2one('account.invoice', 'Invoice')}
|
||||
def copy_data(self, cr, uid, id, default=None, context=None):
|
||||
if default is None:
|
||||
default = {}
|
||||
else:
|
||||
default = default.copy()
|
||||
default = default.copy()
|
||||
default['credit_control_line_ids'] = False
|
||||
return super(AccountInvoice, self).copy_data(
|
||||
cr, uid, id, default=default, context=context)
|
||||
|
||||
@@ -130,7 +130,7 @@ class CreditControlLine(orm.Model):
|
||||
data['date_due'] = move_line.date_maturity
|
||||
data['state'] = 'draft'
|
||||
data['channel'] = level.channel
|
||||
data['invoice_id'] = move_line.invoice_id.id if move_line.invoice_id else False
|
||||
data['invoice_id'] = move_line.invoice.id if move_line.invoice else False
|
||||
data['partner_id'] = move_line.partner_id.id
|
||||
data['amount_due'] = (move_line.amount_currency or move_line.debit or
|
||||
move_line.credit)
|
||||
|
||||
@@ -41,3 +41,12 @@ class ResPartner(orm.Model):
|
||||
string='Credit Control Lines',
|
||||
readonly=True)
|
||||
}
|
||||
|
||||
def copy_data(self, cr, uid, id, default=None, context=None):
|
||||
if default is None:
|
||||
default = {}
|
||||
else:
|
||||
default = default.copy()
|
||||
default['credit_control_line_ids'] = False
|
||||
return super(ResPartner, self).copy_data(
|
||||
cr, uid, id, default=default, context=context)
|
||||
|
||||
@@ -34,8 +34,8 @@ class CreditControlPolicy(Model):
|
||||
'Policy Levels'),
|
||||
|
||||
'do_nothing': fields.boolean('Do nothing',
|
||||
help=('For policies which should not',
|
||||
'generate lines or are obsolete')),
|
||||
help='For policies which should not '
|
||||
'generate lines or are obsolete'),
|
||||
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
|
||||
|
||||
@@ -61,6 +61,18 @@ class CreditControlRun(orm.Model):
|
||||
readonly=True),
|
||||
}
|
||||
|
||||
def copy_data(self, cr, uid, id, default=None, context=None):
|
||||
if default is None:
|
||||
default = {}
|
||||
else:
|
||||
default = default.copy()
|
||||
default.update({
|
||||
'report': False,
|
||||
'manual_ids': False,
|
||||
})
|
||||
return super(CreditControlRun, self).copy_data(
|
||||
cr, uid, id, default=default, context=context)
|
||||
|
||||
def _get_policies(self, cr, uid, context=None):
|
||||
return self.pool['credit.control.policy'].search(cr, uid, [], context=context)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user