[imp] nfu_sale_order_batch_packaging: Add packaging states
This commit is contained in:
parent
91a3e8b8d6
commit
7a7409d4e7
6 changed files with 22 additions and 15 deletions
|
|
@ -38,6 +38,7 @@ 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
|
||||||
|
|
||||||
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.2.1",
|
"version": "16.0.1.3.0",
|
||||||
"depends": ["sale", "sale_order_batch"],
|
"depends": ["sale", "sale_order_batch"],
|
||||||
"data": [
|
"data": [
|
||||||
"views/sale_order_views.xml",
|
"views/sale_order_views.xml",
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ class SaleOrderBatchProduct(models.Model):
|
||||||
|
|
||||||
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_packagin_qty", store=True)
|
||||||
# open_packaging_state = fields.Selection(selection=PACKAGING_STATES, compute="_compute_open_packagin_state")
|
open_packaging_state = fields.Selection(selection=PACKAGING_STATES, compute="_compute_open_packagin_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):
|
||||||
|
|
@ -19,25 +19,27 @@ class SaleOrderBatchProduct(models.Model):
|
||||||
else:
|
else:
|
||||||
product.product_uom_max_qty = False
|
product.product_uom_max_qty = False
|
||||||
|
|
||||||
@api.depends("sale_order_line_ids.product_uom_qty")
|
@api.depends("product_uom_qty")
|
||||||
def _compute_open_packagin_qty(self):
|
def _compute_open_packagin_qty(self):
|
||||||
for product in self:
|
for product in self:
|
||||||
open_packaging_qty = product.product_packaging_qty - (
|
open_packaging_qty = product.product_packaging_qty - (
|
||||||
sum(product.sale_order_line_ids.mapped("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
|
||||||
)
|
)
|
||||||
|
|
||||||
# @api.depends("open_packaging_qty", "product_packaging_qty")
|
@api.depends("open_packaging_qty")
|
||||||
# def _compute_open_packagin_state(self):
|
def _compute_open_packagin_state(self):
|
||||||
# for product in self:
|
for product in self:
|
||||||
# if product.open_packaging_qty == 0:
|
if product.open_packaging_qty == 0:
|
||||||
# product.open_packaging_state = "full"
|
product.open_packaging_state = "full"
|
||||||
# elif product.open_packaging_qty < product.product_packaging_qty:
|
elif (product.product_uom_max_qty - product.product_uom_qty) >= product.open_packaging_qty:
|
||||||
# product.open_packaging_state = "open"
|
product.open_packaging_state = "full"
|
||||||
# else:
|
elif product.product_uom_qty < product.product_packaging_qty:
|
||||||
# product.open_packaging_state = "last_open"
|
product.open_packaging_state = "open"
|
||||||
|
else:
|
||||||
|
product.open_packaging_state = "last_open"
|
||||||
|
|
||||||
@api.model_create_multi
|
@api.model_create_multi
|
||||||
def create(self, vals_list):
|
def create(self, vals_list):
|
||||||
|
|
|
||||||
|
|
@ -3,3 +3,4 @@
|
||||||
: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
|
||||||
|
|
@ -401,6 +401,8 @@ 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>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@
|
||||||
<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_qty != 0)"/>
|
<field name="open_packaging_qty" decoration-warning="(open_packaging_state != 'full')"/>
|
||||||
|
<field name="open_packaging_state"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath
|
<xpath
|
||||||
expr="//field[@name='sale_order_line_ids']/tree/field[@name='product_uom_qty']"
|
expr="//field[@name='sale_order_line_ids']/tree/field[@name='product_uom_qty']"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue