[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
|
||||
- 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
|
||||
:1.3.4: store all quantities and round open values
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
"author": "BAKEUP",
|
||||
"website": "https://www.bakeup.org",
|
||||
"category": "Sale",
|
||||
"version": "16.0.1.3.4",
|
||||
"version": "16.0.1.3.5",
|
||||
"depends": ["sale", "sale_order_batch"],
|
||||
"data": [
|
||||
"data/ir_config_parameter.xml",
|
||||
|
|
|
|||
|
|
@ -7,9 +7,11 @@ PACKAGING_STATES = [("open", "Open"), ("full", "Full"), ("last_open", "Last pack
|
|||
class SaleOrderBatchProduct(models.Model):
|
||||
_inherit = "sale.order.batch.product"
|
||||
|
||||
product_uom_max_qty = fields.Float("Max Qty", compute="_compute_product_uom_max_qty")
|
||||
open_packaging_qty = fields.Float(compute="_compute_open_packaging_qty", store=True)
|
||||
open_packaging_max_qty = fields.Float(compute="_compute_open_packaging_max_qty")
|
||||
product_uom_max_qty = fields.Float(
|
||||
"Max Qty", compute="_compute_product_uom_max_qty", precompute=True, store=True, digits=[12, 3]
|
||||
)
|
||||
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")
|
||||
|
||||
@api.depends("sale_order_line_ids.product_uom_max_qty")
|
||||
|
|
@ -21,11 +23,11 @@ class SaleOrderBatchProduct(models.Model):
|
|||
def _compute_open_packaging_qty(self):
|
||||
for product in self:
|
||||
if product.product_packaging_id:
|
||||
open_packaging_qty = product.product_packaging_qty - (
|
||||
product.product_uom_qty % product.product_packaging_qty
|
||||
open_packaging_qty = product.product_packaging_qty - round(
|
||||
product.product_uom_qty % product.product_packaging_qty, 3
|
||||
)
|
||||
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:
|
||||
product.open_packaging_qty = 0.0
|
||||
|
|
@ -35,8 +37,8 @@ class SaleOrderBatchProduct(models.Model):
|
|||
for product in self:
|
||||
if product.product_packaging_id:
|
||||
if product.product_uom_max_qty < product.product_uom_qty + product.open_packaging_qty:
|
||||
product.open_packaging_max_qty = product.product_packaging_qty - (
|
||||
product.product_uom_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, 3
|
||||
)
|
||||
else:
|
||||
product.open_packaging_max_qty = 0.0
|
||||
|
|
|
|||
|
|
@ -11,4 +11,5 @@
|
|||
- on creation set max_qty to product_uom_qty if not set
|
||||
- remove zero exception for max_qty
|
||||
- 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>
|
||||
</td>
|
||||
</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>remove zero exception for max_qty</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>
|
||||
</td>
|
||||
</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>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@
|
|||
<field name="product_uom_max_qty"/>
|
||||
<field
|
||||
name="open_packaging_qty"
|
||||
decoration-warning="(open_packaging_state != 0) and not (open_packaging_max_qty != 0)"
|
||||
decoration-danger="(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.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"/>
|
||||
</xpath>
|
||||
<xpath
|
||||
|
|
|
|||
Loading…
Reference in a new issue