[IMP] nfu_sale_order_batch_packaging: add open_max_qty
This commit is contained in:
parent
f4b65e693c
commit
1a77c5ed98
6 changed files with 44 additions and 22 deletions
|
|
@ -38,7 +38,8 @@ Changelog
|
||||||
:1.1.0: Live
|
:1.1.0: Live
|
||||||
:1.2.0: Add regeneration action for batch products
|
:1.2.0: Add regeneration action for batch products
|
||||||
:1.2.1: refactoring
|
:1.2.1: refactoring
|
||||||
:1.3.0: add packagin states
|
:1.3.0: add packaging states
|
||||||
|
:1.3.1: add open_max_qty
|
||||||
|
|
||||||
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.0",
|
"version": "16.0.1.3.1",
|
||||||
"depends": ["sale", "sale_order_batch"],
|
"depends": ["sale", "sale_order_batch"],
|
||||||
"data": [
|
"data": [
|
||||||
"views/sale_order_views.xml",
|
"views/sale_order_views.xml",
|
||||||
|
|
|
||||||
|
|
@ -8,33 +8,45 @@ 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("Max Qty", compute="_compute_product_uom_max_qty")
|
||||||
open_packaging_qty = fields.Float(compute="_compute_open_packagin_qty", store=True)
|
open_packaging_qty = fields.Float(compute="_compute_open_packaging_qty")
|
||||||
open_packaging_state = fields.Selection(selection=PACKAGING_STATES, compute="_compute_open_packagin_state")
|
open_packaging_max_qty = fields.Float(compute="_compute_open_packaging_max_qty")
|
||||||
|
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")
|
||||||
def _compute_product_uom_max_qty(self):
|
def _compute_product_uom_max_qty(self):
|
||||||
for product in self:
|
for product in self:
|
||||||
if product.sale_order_line_ids:
|
|
||||||
product.product_uom_max_qty = sum(product.sale_order_line_ids.mapped("product_uom_max_qty"))
|
product.product_uom_max_qty = sum(product.sale_order_line_ids.mapped("product_uom_max_qty"))
|
||||||
else:
|
|
||||||
product.product_uom_max_qty = False
|
|
||||||
|
|
||||||
@api.depends("product_uom_qty")
|
@api.depends("product_uom_qty")
|
||||||
def _compute_open_packagin_qty(self):
|
def _compute_open_packaging_qty(self):
|
||||||
for product in self:
|
for product in self:
|
||||||
|
if product.product_packaging_id:
|
||||||
open_packaging_qty = product.product_packaging_qty - (
|
open_packaging_qty = product.product_packaging_qty - (
|
||||||
product.product_uom_qty % product.product_packaging_qty
|
product.product_uom_qty % product.product_packaging_qty
|
||||||
)
|
)
|
||||||
product.open_packaging_qty = (
|
product.open_packaging_qty = (
|
||||||
0 if open_packaging_qty == product.product_packaging_qty else open_packaging_qty
|
0 if open_packaging_qty == product.product_packaging_qty else open_packaging_qty
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
product.open_packaging_qty = 0.0
|
||||||
|
|
||||||
|
@api.depends("product_uom_max_qty")
|
||||||
|
def _compute_open_packaging_max_qty(self):
|
||||||
|
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
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
product.open_packaging_max_qty = 0.0
|
||||||
|
else:
|
||||||
|
product.open_packaging_max_qty = 0.0
|
||||||
|
|
||||||
@api.depends("open_packaging_qty")
|
@api.depends("open_packaging_qty")
|
||||||
def _compute_open_packagin_state(self):
|
def _compute_open_packaging_state(self):
|
||||||
for product in self:
|
for product in self:
|
||||||
if product.open_packaging_qty == 0:
|
if product.open_packaging_qty == 0 or product.open_packaging_max_qty == 0:
|
||||||
product.open_packaging_state = "full"
|
|
||||||
elif (product.product_uom_max_qty - product.product_uom_qty) >= product.open_packaging_qty:
|
|
||||||
product.open_packaging_state = "full"
|
product.open_packaging_state = "full"
|
||||||
elif product.product_uom_qty < product.product_packaging_qty:
|
elif product.product_uom_qty < product.product_packaging_qty:
|
||||||
product.open_packaging_state = "open"
|
product.open_packaging_state = "open"
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,5 @@
|
||||||
:1.1.0: Live
|
:1.1.0: Live
|
||||||
:1.2.0: Add regeneration action for batch products
|
:1.2.0: Add regeneration action for batch products
|
||||||
:1.2.1: refactoring
|
:1.2.1: refactoring
|
||||||
:1.3.0: add packagin states
|
:1.3.0: add packaging states
|
||||||
|
:1.3.1: add open_max_qty
|
||||||
|
|
@ -401,7 +401,9 @@ and adds a packaging default to sale order batch.</p>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="field"><th class="field-name">1.2.1:</th><td class="field-body">refactoring</td>
|
<tr class="field"><th class="field-name">1.2.1:</th><td class="field-body">refactoring</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="field"><th class="field-name">1.3.0:</th><td class="field-body">add packagin states</td>
|
<tr class="field"><th class="field-name">1.3.0:</th><td class="field-body">add packaging states</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="field"><th class="field-name">1.3.1:</th><td class="field-body">add open_max_qty</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,13 @@
|
||||||
<field name="inherit_id" ref="sale_order_batch.view_order_batch_product_form"/>
|
<field name="inherit_id" ref="sale_order_batch.view_order_batch_product_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//group[@name='product_info']" position="inside">
|
<xpath expr="//group[@name='product_info']" position="inside">
|
||||||
<field name="open_packaging_qty" decoration-warning="(open_packaging_state != 'full')"/>
|
<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)"
|
||||||
|
/>
|
||||||
|
<field name="open_packaging_max_qty" decoration-danger="(open_packaging_max_qty != 0)"/>
|
||||||
<field name="open_packaging_state"/>
|
<field name="open_packaging_state"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath
|
<xpath
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue