[IMP] sale: Remove qty_delivered_manual field
This field is useless since the new compute method from 13.0. And also introduces side effect / loop recomputations.
This commit is contained in:
@@ -282,9 +282,6 @@ class SaleOrderLine(models.Model):
|
|||||||
'Delivered Quantity', copy=False,
|
'Delivered Quantity', copy=False,
|
||||||
compute='_compute_qty_delivered', store=True, readonly=False,
|
compute='_compute_qty_delivered', store=True, readonly=False,
|
||||||
digits='Product Unit of Measure')
|
digits='Product Unit of Measure')
|
||||||
qty_delivered_manual = fields.Float(
|
|
||||||
'Delivered Manually', copy=False, digits='Product Unit of Measure',
|
|
||||||
compute='_compute_qty_delivered_manual', store=True, readonly=False)
|
|
||||||
qty_to_invoice = fields.Float(
|
qty_to_invoice = fields.Float(
|
||||||
compute='_get_to_invoice_qty', string='To Invoice Quantity', store=True,
|
compute='_get_to_invoice_qty', string='To Invoice Quantity', store=True,
|
||||||
digits='Product Unit of Measure')
|
digits='Product Unit of Measure')
|
||||||
@@ -349,7 +346,11 @@ class SaleOrderLine(models.Model):
|
|||||||
else: # service and consu
|
else: # service and consu
|
||||||
line.qty_delivered_method = 'manual'
|
line.qty_delivered_method = 'manual'
|
||||||
|
|
||||||
@api.depends('qty_delivered_method', 'qty_delivered_manual', 'analytic_line_ids.so_line', 'analytic_line_ids.unit_amount', 'analytic_line_ids.product_uom_id')
|
@api.depends(
|
||||||
|
'qty_delivered_method',
|
||||||
|
'analytic_line_ids.so_line',
|
||||||
|
'analytic_line_ids.unit_amount',
|
||||||
|
'analytic_line_ids.product_uom_id')
|
||||||
def _compute_qty_delivered(self):
|
def _compute_qty_delivered(self):
|
||||||
""" This method compute the delivered quantity of the SO lines: it covers the case provide by sale module, aka
|
""" This method compute the delivered quantity of the SO lines: it covers the case provide by sale module, aka
|
||||||
expense/vendor bills (sum of unit_amount of AAL), and manual case.
|
expense/vendor bills (sum of unit_amount of AAL), and manual case.
|
||||||
@@ -362,10 +363,6 @@ class SaleOrderLine(models.Model):
|
|||||||
mapping = lines_by_analytic._get_delivered_quantity_by_analytic([('amount', '<=', 0.0)])
|
mapping = lines_by_analytic._get_delivered_quantity_by_analytic([('amount', '<=', 0.0)])
|
||||||
for so_line in lines_by_analytic:
|
for so_line in lines_by_analytic:
|
||||||
so_line.qty_delivered = mapping.get(so_line.id or so_line._origin.id, 0.0)
|
so_line.qty_delivered = mapping.get(so_line.id or so_line._origin.id, 0.0)
|
||||||
# compute for manual lines
|
|
||||||
for line in self:
|
|
||||||
if line.qty_delivered_method == 'manual':
|
|
||||||
line.qty_delivered = line.qty_delivered_manual or 0.0
|
|
||||||
|
|
||||||
def _get_delivered_quantity_by_analytic(self, additional_domain):
|
def _get_delivered_quantity_by_analytic(self, additional_domain):
|
||||||
""" Compute and write the delivered quantity of current SO lines, based on their related
|
""" Compute and write the delivered quantity of current SO lines, based on their related
|
||||||
@@ -406,17 +403,6 @@ class SaleOrderLine(models.Model):
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@api.depends('qty_delivered', 'qty_delivered_method')
|
|
||||||
def _compute_qty_delivered_manual(self):
|
|
||||||
""" When writing on qty_delivered, if the value should be
|
|
||||||
modified manually (`qty_delivered_method` = 'manual' only),
|
|
||||||
then we put the value in `qty_delivered_manual`.
|
|
||||||
Otherwise, `qty_delivered_manual` should be False since the
|
|
||||||
delivered qty is automatically computed by other mecanisms.
|
|
||||||
"""
|
|
||||||
for line in self:
|
|
||||||
line.qty_delivered_manual = line.qty_delivered if line.qty_delivered_method == 'manual' else 0.0
|
|
||||||
|
|
||||||
@api.depends('product_id', 'product_uom_qty', 'product_uom')
|
@api.depends('product_id', 'product_uom_qty', 'product_uom')
|
||||||
def _compute_product_packaging_id(self):
|
def _compute_product_packaging_id(self):
|
||||||
for line in self:
|
for line in self:
|
||||||
|
|||||||
@@ -378,7 +378,6 @@
|
|||||||
/>
|
/>
|
||||||
<field name="invoice_status" invisible="1"/>
|
<field name="invoice_status" invisible="1"/>
|
||||||
<field name="qty_to_invoice" invisible="1"/>
|
<field name="qty_to_invoice" invisible="1"/>
|
||||||
<field name="qty_delivered_manual" invisible="1"/>
|
|
||||||
<field name="qty_delivered_method" invisible="1"/>
|
<field name="qty_delivered_method" invisible="1"/>
|
||||||
<field name="price_total" invisible="1"/>
|
<field name="price_total" invisible="1"/>
|
||||||
<field name="price_tax" invisible="1"/>
|
<field name="price_tax" invisible="1"/>
|
||||||
@@ -528,7 +527,6 @@
|
|||||||
}"
|
}"
|
||||||
optional="show"
|
optional="show"
|
||||||
/>
|
/>
|
||||||
<field name="qty_delivered_manual" invisible="1"/>
|
|
||||||
<field name="qty_delivered_method" invisible="1"/>
|
<field name="qty_delivered_method" invisible="1"/>
|
||||||
<field
|
<field
|
||||||
name="qty_invoiced"
|
name="qty_invoiced"
|
||||||
|
|||||||
Reference in New Issue
Block a user