Support amend line without product
issue9811 review331611002
This commit is contained in:
1 parent
9d02a97348
commit
4fd6f3350f
3 files changed
+39
-13
No files matched your search
@@ -1,3 +1,5 @@
|
||||
* Support amend line without product
|
||||
|
||||
Version 5.8.0 - 2020-11-02
|
||||
* Bug fixes (see mercurial logs for details)
|
||||
* Remove support for Python 3.5
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
from trytond.i18n import gettext
|
||||
from trytond.model import ModelSQL, ModelView, Workflow, fields
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.pyson import Eval, If
|
||||
from trytond.pyson import Eval, If, Bool
|
||||
|
||||
from trytond.modules.product import price_digits
|
||||
|
||||
@@ -267,12 +267,13 @@ class AmendmentLine(ModelSQL, ModelView):
|
||||
If(Eval('state') == 'draft',
|
||||
('salable', '=', True),
|
||||
()),
|
||||
('default_uom_category', '=', Eval('product_uom_category')),
|
||||
If(Eval('product_uom_category'),
|
||||
('default_uom_category', '=', Eval('product_uom_category')),
|
||||
()),
|
||||
],
|
||||
states={
|
||||
'readonly': Eval('state') != 'draft',
|
||||
'invisible': Eval('action') != 'line',
|
||||
'required': Eval('action') == 'line',
|
||||
},
|
||||
depends=['action', 'state', 'product_uom_category'])
|
||||
quantity = fields.Float(
|
||||
@@ -287,14 +288,16 @@ class AmendmentLine(ModelSQL, ModelView):
|
||||
unit = fields.Many2One(
|
||||
'product.uom', "Unit", ondelete='RESTRICT',
|
||||
domain=[
|
||||
('category', '=', Eval('product_uom_category')),
|
||||
If(Eval('product_uom_category'),
|
||||
('category', '=', Eval('product_uom_category')),
|
||||
()),
|
||||
],
|
||||
states={
|
||||
'readonly': Eval('state') != 'draft',
|
||||
'invisible': Eval('action') != 'line',
|
||||
'required': Eval('action') == 'line',
|
||||
'required': Bool(Eval('product')),
|
||||
},
|
||||
depends=['state', 'product_uom_category', 'action'])
|
||||
depends=['state', 'product_uom_category', 'action', 'product'])
|
||||
unit_price = fields.Numeric(
|
||||
"Unit Price", digits=price_digits,
|
||||
states={
|
||||
@@ -406,7 +409,10 @@ class AmendmentLine(ModelSQL, ModelView):
|
||||
@fields.depends('line')
|
||||
def on_change_with_product_uom_category(self, name=None):
|
||||
if self.line:
|
||||
return self.line.product_uom_category.id
|
||||
if self.line.product_uom_category:
|
||||
return self.line.product_uom_category.id
|
||||
elif self.line.unit:
|
||||
return self.line.unit.category.id
|
||||
|
||||
def apply(self, sale):
|
||||
assert self.sale == sale
|
||||
@@ -420,7 +426,8 @@ class AmendmentLine(ModelSQL, ModelView):
|
||||
|
||||
def _apply_taxes(self, sale, sale_line):
|
||||
for line in sale.lines:
|
||||
line.taxes = line.compute_taxes(sale.party)
|
||||
if line.product:
|
||||
line.taxes = line.compute_taxes(sale.party)
|
||||
|
||||
def _apply_payment_term(self, sale, sale_line):
|
||||
sale.payment_term = self.payment_term
|
||||
|
||||
@@ -78,6 +78,9 @@ Sale first product::
|
||||
>>> sale_line = sale.lines.new()
|
||||
>>> sale_line.product = product1
|
||||
>>> sale_line.quantity = 5.0
|
||||
>>> sale_line = sale.lines.new()
|
||||
>>> sale_line.quantity = 1
|
||||
>>> sale_line.unit_price = Decimal('5.0000')
|
||||
>>> sale.click('quote')
|
||||
>>> sale.click('confirm')
|
||||
>>> sale.state
|
||||
@@ -85,7 +88,7 @@ Sale first product::
|
||||
>>> sale.revision
|
||||
0
|
||||
>>> sale.total_amount
|
||||
Decimal('50.00')
|
||||
Decimal('55.00')
|
||||
>>> len(sale.shipments), len(sale.invoices)
|
||||
(1, 1)
|
||||
|
||||
@@ -107,7 +110,7 @@ Add an amendment::
|
||||
True
|
||||
>>> line = amendment.lines.new()
|
||||
>>> line.action = 'line'
|
||||
>>> line.line, = sale.lines
|
||||
>>> line.line = sale.lines[0]
|
||||
>>> line.product == product1
|
||||
True
|
||||
>>> line.product = product2
|
||||
@@ -117,6 +120,11 @@ Add an amendment::
|
||||
>>> line.unit_price
|
||||
Decimal('10.0000')
|
||||
>>> line.unit_price = Decimal('9.0000')
|
||||
>>> line = amendment.lines.new()
|
||||
>>> line.action = 'line'
|
||||
>>> line.line = sale.lines[1]
|
||||
>>> line.product
|
||||
>>> line.quantity = 2
|
||||
>>> amendment.save()
|
||||
|
||||
Validate amendment::
|
||||
@@ -127,15 +135,18 @@ Validate amendment::
|
||||
1
|
||||
>>> sale.party == customer2
|
||||
True
|
||||
>>> line, = sale.lines
|
||||
>>> line = sale.lines[0]
|
||||
>>> line.product == product2
|
||||
True
|
||||
>>> line.quantity
|
||||
4.0
|
||||
>>> line.unit_price
|
||||
Decimal('9.0000')
|
||||
>>> line = sale.lines[1]
|
||||
>>> line.quantity
|
||||
2.0
|
||||
>>> sale.total_amount
|
||||
Decimal('36.00')
|
||||
Decimal('46.00')
|
||||
|
||||
>>> shipment, = sale.shipments
|
||||
>>> move, = shipment.outgoing_moves
|
||||
@@ -145,10 +156,16 @@ Validate amendment::
|
||||
4.0
|
||||
|
||||
>>> invoice, = sale.invoices
|
||||
>>> line, = invoice.lines
|
||||
>>> line = invoice.lines[0]
|
||||
>>> line.product == product2
|
||||
True
|
||||
>>> line.quantity
|
||||
4.0
|
||||
>>> line.unit_price
|
||||
Decimal('9.0000')
|
||||
>>> line = invoice.lines[1]
|
||||
>>> line.product
|
||||
>>> line.quantity
|
||||
2.0
|
||||
>>> line.unit_price
|
||||
Decimal('5.0000')
|
||||
Reference in new issue
Block a user