[IMP] sale: prevent copying down payments when duplicating a SO

This commit is contained in:
keyur gajjar
2016-10-14 14:03:26 +02:00
committed by Denis Vermylen (dve)
parent b008d8ea86
commit f7cf5a2e15
2 changed files with 12 additions and 0 deletions
+11
View File
@@ -263,6 +263,14 @@ class SaleOrder(models.Model):
result = super(SaleOrder, self).create(vals)
return result
@api.multi
def copy_data(self, default=None):
if default is None:
default = {}
if 'order_line' not in default:
default['order_line'] = [(0, 0, line.copy_data()[0]) for line in self.order_line.filtered(lambda l: not l.is_downpayment)]
return super(SaleOrder, self).copy_data(default)
@api.multi
def _prepare_invoice(self):
"""
@@ -740,6 +748,9 @@ class SaleOrderLine(models.Model):
company_id = fields.Many2one(related='order_id.company_id', string='Company', store=True, readonly=True)
order_partner_id = fields.Many2one(related='order_id.partner_id', store=True, string='Customer')
analytic_tag_ids = fields.Many2many('account.analytic.tag', string='Analytic Tags')
is_downpayment = fields.Boolean(
string="Is a down payment", help="Down payments are made when creating invoices from a sale order."
" They are not copied when duplicating a sale order.")
state = fields.Selection([
('draft', 'Quotation'),
@@ -151,6 +151,7 @@ class SaleAdvancePaymentInv(models.TransientModel):
'product_uom': self.product_id.uom_id.id,
'product_id': self.product_id.id,
'tax_id': [(6, 0, self.product_id.taxes_id.ids)],
'is_downpayment': True,
})
self._create_invoice(order, so_line, amount)
if self._context.get('open_invoices', False):