[FIX] nfu_sale_order_batch_packaging: store all quantities and round open values
This commit is contained in:
parent
e1a8a5128a
commit
bcedb0b897
6 changed files with 21 additions and 14 deletions
|
|
@ -47,6 +47,7 @@ Changelog
|
||||||
- remove zero exception for max_qty
|
- remove zero exception for max_qty
|
||||||
- store open_packaging_qty on batch product module to make it sortable
|
- store open_packaging_qty on batch product module to make it sortable
|
||||||
- always adjust max_qty to be at least uom_qty except you only set max qty
|
- always adjust max_qty to be at least uom_qty except you only set max qty
|
||||||
|
:1.3.4: store all quantities and round open values
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"author": "BAKEUP",
|
"author": "BAKEUP",
|
||||||
"website": "https://www.bakeup.org",
|
"website": "https://www.bakeup.org",
|
||||||
"category": "Sale",
|
"category": "Sale",
|
||||||
"version": "16.0.1.3.4",
|
"version": "16.0.1.3.5",
|
||||||
"depends": ["sale", "sale_order_batch"],
|
"depends": ["sale", "sale_order_batch"],
|
||||||
"data": [
|
"data": [
|
||||||
"data/ir_config_parameter.xml",
|
"data/ir_config_parameter.xml",
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,11 @@ PACKAGING_STATES = [("open", "Open"), ("full", "Full"), ("last_open", "Last pack
|
||||||
class SaleOrderBatchProduct(models.Model):
|
class SaleOrderBatchProduct(models.Model):
|
||||||
_inherit = "sale.order.batch.product"
|
_inherit = "sale.order.batch.product"
|
||||||
|
|
||||||
product_uom_max_qty = fields.Float("Max Qty", compute="_compute_product_uom_max_qty")
|
product_uom_max_qty = fields.Float(
|
||||||
open_packaging_qty = fields.Float(compute="_compute_open_packaging_qty", store=True)
|
"Max Qty", compute="_compute_product_uom_max_qty", precompute=True, store=True, digits=[12, 3]
|
||||||
open_packaging_max_qty = fields.Float(compute="_compute_open_packaging_max_qty")
|
)
|
||||||
|
open_packaging_qty = fields.Float(compute="_compute_open_packaging_qty", store=True, digits=[12, 3])
|
||||||
|
open_packaging_max_qty = fields.Float(compute="_compute_open_packaging_max_qty", store=True, digits=[12, 3])
|
||||||
open_packaging_state = fields.Selection(selection=PACKAGING_STATES, compute="_compute_open_packaging_state")
|
open_packaging_state = fields.Selection(selection=PACKAGING_STATES, compute="_compute_open_packaging_state")
|
||||||
|
|
||||||
@api.depends("sale_order_line_ids.product_uom_max_qty")
|
@api.depends("sale_order_line_ids.product_uom_max_qty")
|
||||||
|
|
@ -21,11 +23,11 @@ class SaleOrderBatchProduct(models.Model):
|
||||||
def _compute_open_packaging_qty(self):
|
def _compute_open_packaging_qty(self):
|
||||||
for product in self:
|
for product in self:
|
||||||
if product.product_packaging_id:
|
if product.product_packaging_id:
|
||||||
open_packaging_qty = product.product_packaging_qty - (
|
open_packaging_qty = product.product_packaging_qty - round(
|
||||||
product.product_uom_qty % product.product_packaging_qty
|
product.product_uom_qty % product.product_packaging_qty, 3
|
||||||
)
|
)
|
||||||
product.open_packaging_qty = (
|
product.open_packaging_qty = (
|
||||||
0 if open_packaging_qty == product.product_packaging_qty else open_packaging_qty
|
0.0 if open_packaging_qty == product.product_packaging_qty else open_packaging_qty
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
product.open_packaging_qty = 0.0
|
product.open_packaging_qty = 0.0
|
||||||
|
|
@ -35,8 +37,8 @@ class SaleOrderBatchProduct(models.Model):
|
||||||
for product in self:
|
for product in self:
|
||||||
if product.product_packaging_id:
|
if product.product_packaging_id:
|
||||||
if product.product_uom_max_qty < product.product_uom_qty + product.open_packaging_qty:
|
if product.product_uom_max_qty < product.product_uom_qty + product.open_packaging_qty:
|
||||||
product.open_packaging_max_qty = product.product_packaging_qty - (
|
product.open_packaging_max_qty = product.product_packaging_qty - round(
|
||||||
product.product_uom_max_qty % product.product_packaging_qty
|
product.product_uom_max_qty % product.product_packaging_qty, 3
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
product.open_packaging_max_qty = 0.0
|
product.open_packaging_max_qty = 0.0
|
||||||
|
|
|
||||||
|
|
@ -12,3 +12,4 @@
|
||||||
- remove zero exception for max_qty
|
- remove zero exception for max_qty
|
||||||
- store open_packaging_qty on batch product module to make it sortable
|
- store open_packaging_qty on batch product module to make it sortable
|
||||||
- always adjust max_qty to be at least uom_qty except you only set max qty
|
- always adjust max_qty to be at least uom_qty except you only set max qty
|
||||||
|
:1.3.4: store all quantities and round open values
|
||||||
|
|
@ -418,7 +418,7 @@ and adds a packaging default to sale order batch.</p>
|
||||||
<tr class="field"><th class="field-name">1.3.3:</th><td class="field-body"><p class="first">Enable packagings on installation</p>
|
<tr class="field"><th class="field-name">1.3.3:</th><td class="field-body"><p class="first">Enable packagings on installation</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="field"><th class="field-name">1.3.4:</th><td class="field-body"><ul class="first last simple">
|
<tr class="field"><th class="field-name">1.3.4:</th><td class="field-body"><ul class="first simple">
|
||||||
<li>on creation set max_qty to product_uom_qty if not set</li>
|
<li>on creation set max_qty to product_uom_qty if not set</li>
|
||||||
<li>remove zero exception for max_qty</li>
|
<li>remove zero exception for max_qty</li>
|
||||||
<li>store open_packaging_qty on batch product module to make it sortable</li>
|
<li>store open_packaging_qty on batch product module to make it sortable</li>
|
||||||
|
|
@ -426,6 +426,9 @@ and adds a packaging default to sale order batch.</p>
|
||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="field"><th class="field-name">1.3.4:</th><td class="field-body"><p class="first last">store all quantities and round open values</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,10 @@
|
||||||
<field name="product_uom_max_qty"/>
|
<field name="product_uom_max_qty"/>
|
||||||
<field
|
<field
|
||||||
name="open_packaging_qty"
|
name="open_packaging_qty"
|
||||||
decoration-warning="(open_packaging_state != 0) and not (open_packaging_max_qty != 0)"
|
decoration-warning="open_packaging_qty != 0.0 and open_packaging_max_qty == 0.0"
|
||||||
decoration-danger="(open_packaging_max_qty != 0)"
|
decoration-danger="open_packaging_max_qty != 0.0"
|
||||||
/>
|
/>
|
||||||
<field name="open_packaging_max_qty" decoration-danger="(open_packaging_max_qty != 0)"/>
|
<field name="open_packaging_max_qty" decoration-danger="(open_packaging_max_qty != 0.0)"/>
|
||||||
<field name="open_packaging_state"/>
|
<field name="open_packaging_state"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath
|
<xpath
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue