diff --git a/CHANGELOG b/CHANGELOG index bf196ca6df..7741815c34 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Don't set default unit price on invoice line * Allow to modify some fields of posted invoice line Version 3.6.0 - 2015-04-20 diff --git a/invoice.py b/invoice.py index a706fb1f64..e8ed607c35 100644 --- a/invoice.py +++ b/invoice.py @@ -1691,16 +1691,11 @@ class InvoiceLine(ModelSQL, ModelView, TaxableMixin): ''' return {} - @fields.depends('product', 'unit', 'quantity', 'description', - '_parent_invoice.type', '_parent_invoice.party', - '_parent_invoice.currency', '_parent_invoice.currency_date', - 'party', 'currency', 'invoice', 'invoice_type') + @fields.depends('product', 'unit', 'description', '_parent_invoice.type', + '_parent_invoice.party', 'party', 'invoice', 'invoice_type') def on_change_product(self): pool = Pool() Product = pool.get('product.product') - Company = pool.get('company.company') - Currency = pool.get('currency.currency') - Date = pool.get('ir.date') if not self.product: return @@ -1714,31 +1709,11 @@ class InvoiceLine(ModelSQL, ModelView, TaxableMixin): if party and party.lang: context['language'] = party.lang.code - company = None - if Transaction().context.get('company'): - company = Company(Transaction().context['company']) - currency = None - currency_date = Date.today() - if self.invoice and self.invoice.currency_date: - currency_date = self.invoice.currency_date - # TODO check if today date is correct - if self.invoice and self.invoice.currency: - currency = self.invoice.currency - elif self.currency: - currency = self.currency - if self.invoice and self.invoice.type: type_ = self.invoice.type else: type_ = self.invoice_type if type_ in ('in_invoice', 'in_credit_note'): - if company and currency: - with Transaction().set_context(date=currency_date): - self.unit_price = Currency.compute( - company.currency, self.product.cost_price, - currency, round=False) - else: - self.unit_price = self.product.cost_price try: self.account = self.product.account_expense_used except Exception: @@ -1758,13 +1733,6 @@ class InvoiceLine(ModelSQL, ModelView, TaxableMixin): taxes.extend(tax_ids) self.taxes = taxes else: - if company and currency: - with Transaction().set_context(date=currency_date): - self.unit_price = Currency.compute( - company.currency, self.product.list_price, - currency, round=False) - else: - self.unit_price = self.product.list_price try: self.account = self.product.account_revenue_used except Exception: @@ -1793,9 +1761,6 @@ class InvoiceLine(ModelSQL, ModelView, TaxableMixin): self.unit = self.product.default_uom.id self.unit_digits = self.product.default_uom.digits - self.type = 'line' - self.amount = self.on_change_with_amount() - @fields.depends('product') def on_change_with_product_uom_category(self, name=None): if self.product: diff --git a/tests/scenario_invoice.rst b/tests/scenario_invoice.rst index 2526648683..95cd36802b 100644 --- a/tests/scenario_invoice.rst +++ b/tests/scenario_invoice.rst @@ -106,6 +106,7 @@ Create invoice:: >>> invoice.lines.append(line) >>> line.product = product >>> line.quantity = 5 + >>> line.unit_price = Decimal('40') >>> line = InvoiceLine() >>> invoice.lines.append(line) >>> line.account = revenue diff --git a/tests/scenario_invoice_alternate_currency.rst b/tests/scenario_invoice_alternate_currency.rst index 981ecab4a6..197dad64bd 100644 --- a/tests/scenario_invoice_alternate_currency.rst +++ b/tests/scenario_invoice_alternate_currency.rst @@ -107,6 +107,7 @@ Create invoice with alternate currency:: >>> line = invoice.lines.new() >>> line.product = product >>> line.quantity = 5 + >>> line.unit_price = Decimal('80') >>> line.amount Decimal('400.00') >>> line = invoice.lines.new() @@ -146,6 +147,7 @@ Create invoice with alternate currency and negative taxes:: >>> line = invoice.lines.new() >>> line.product = product >>> line.quantity = 5 + >>> line.unit_price = Decimal('80') >>> _ = line.taxes.pop(0) >>> line.taxes.append(negative_tax) >>> line.amount diff --git a/tests/scenario_invoice_supplier.rst b/tests/scenario_invoice_supplier.rst index 896fb7d7ee..cb1e565215 100644 --- a/tests/scenario_invoice_supplier.rst +++ b/tests/scenario_invoice_supplier.rst @@ -104,6 +104,7 @@ Create invoice:: >>> invoice.lines.append(line) >>> line.product = product >>> line.quantity = 5 + >>> line.unit_price = Decimal('20') >>> line = InvoiceLine() >>> invoice.lines.append(line) >>> line.account = expense @@ -178,6 +179,7 @@ Create a posted and a draft invoice to cancel:: >>> line = invoice.lines.new() >>> line.product = product >>> line.quantity = 1 + >>> line.unit_price = Decimal('20') >>> invoice.click('post') >>> invoice_draft, = Invoice.duplicate([invoice])