summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorkeyur gajjar <kga@odoo.com>2016-06-21 15:43:36 +0530
committerDenis Vermylen (dve) <dve@odoo.com>2016-10-14 14:03:26 +0200
commitf7cf5a2e15f3f0e9dc4795068e797daabe389c4e (patch)
tree21b6f99cbe4c54e770b1e57d507d8fdfae55b0f6 /addons
parentb008d8ea86ee41d210fb941e90652deb1b874a24 (diff)
[IMP] sale: prevent copying down payments when duplicating a SO
Diffstat (limited to 'addons')
-rw-r--r--addons/sale/models/sale.py11
-rw-r--r--addons/sale/wizard/sale_make_invoice_advance.py1
2 files changed, 12 insertions, 0 deletions
diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py
index cd31f17aabc..35aa4f067c6 100644
--- a/addons/sale/models/sale.py
+++ b/addons/sale/models/sale.py
@@ -264,6 +264,14 @@ class SaleOrder(models.Model):
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):
"""
Prepare the dict of values to create the new invoice for a sales order. This method may be
@@ -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'),
diff --git a/addons/sale/wizard/sale_make_invoice_advance.py b/addons/sale/wizard/sale_make_invoice_advance.py
index 838f9abde22..e3dbc4ed176 100644
--- a/addons/sale/wizard/sale_make_invoice_advance.py
+++ b/addons/sale/wizard/sale_make_invoice_advance.py
@@ -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):