mirror of
https://github.com/NaN-tic/trytond-patches.git
synced 2023-12-14 06:03:03 +01:00
45 lines
1.9 KiB
Diff
45 lines
1.9 KiB
Diff
# http://codereview.tryton.org/5871002/
|
|
|
|
diff -r 46c9a4316548 sale.py
|
|
--- a/modules/sale/sale.py Thu Dec 04 23:41:16 2014 +0100
|
|
+++ b/modules/sale/sale.py Wed Dec 17 21:27:11 2014 +0100
|
|
@@ -15,6 +15,8 @@
|
|
from trytond.pyson import If, Eval, Bool, PYSONEncoder, Id
|
|
from trytond.transaction import Transaction
|
|
from trytond.pool import Pool, PoolMeta
|
|
+from trytond.config import config
|
|
+DIGITS = config.getint('digits', 'unit_price_digits', 4)
|
|
|
|
__all__ = ['Sale', 'SaleIgnoredInvoice', 'SaleRecreatedInvoice',
|
|
'SaleLine', 'SaleLineTax', 'SaleLineIgnoredMove',
|
|
@@ -1029,7 +1031,7 @@
|
|
product_uom_category = fields.Function(
|
|
fields.Many2One('product.uom.category', 'Product Uom Category'),
|
|
'on_change_with_product_uom_category')
|
|
- unit_price = fields.Numeric('Unit Price', digits=(16, 4),
|
|
+ unit_price = fields.Numeric('Unit Price', digits=(16, DIGITS),
|
|
states={
|
|
'invisible': Eval('type') != 'line',
|
|
'required': Eval('type') == 'line',
|
|
@@ -1047,6 +1049,8 @@
|
|
domain=[('parent', '=', None), ['OR',
|
|
('group', '=', None),
|
|
('group.kind', 'in', ['sale', 'both'])],
|
|
+ ('company', '=',
|
|
+ Eval('_parent_sale', {}).get('company', -1)),
|
|
],
|
|
states={
|
|
'invisible': Eval('type') != 'line',
|
|
@@ -1365,8 +1369,10 @@
|
|
if old_invoice_line.type != 'line':
|
|
continue
|
|
if old_invoice_line.id not in skip_ids:
|
|
+ sign = (1.0 if invoice_type == old_invoice_line.invoice_type
|
|
+ else -1.0)
|
|
quantity -= Uom.compute_qty(old_invoice_line.unit,
|
|
- old_invoice_line.quantity, self.unit)
|
|
+ sign * old_invoice_line.quantity, self.unit)
|
|
|
|
rounding = self.unit.rounding if self.unit else 0.01
|
|
invoice_line.quantity = Uom.round(quantity, rounding)
|