[FIX] nfu_sale_order_batch_packaging: make open_packaging_qty sortable
This commit is contained in:
parent
5c04eda4cb
commit
57bb70b6c7
7 changed files with 41 additions and 14 deletions
|
|
@ -42,6 +42,10 @@ Changelog
|
||||||
:1.3.1: add open_max_qty
|
:1.3.1: add open_max_qty
|
||||||
:1.3.2: fix color indicator
|
:1.3.2: fix color indicator
|
||||||
:1.3.3: Enable packagings on installation
|
:1.3.3: Enable packagings on installation
|
||||||
|
:1.3.4:
|
||||||
|
- 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
|
||||||
|
|
||||||
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.3",
|
"version": "16.0.1.3.4",
|
||||||
"depends": ["sale", "sale_order_batch"],
|
"depends": ["sale", "sale_order_batch"],
|
||||||
"data": [
|
"data": [
|
||||||
"data/ir_config_parameter.xml",
|
"data/ir_config_parameter.xml",
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ 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_packaging_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")
|
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")
|
open_packaging_state = fields.Selection(selection=PACKAGING_STATES, compute="_compute_open_packaging_state")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ class SaleOrderLine(models.Model):
|
||||||
@api.constrains("product_uom_qty", "product_uom_max_qty")
|
@api.constrains("product_uom_qty", "product_uom_max_qty")
|
||||||
def _check_product_uom_qty(self):
|
def _check_product_uom_qty(self):
|
||||||
for order_line in self:
|
for order_line in self:
|
||||||
if order_line.product_uom_max_qty != 0 and order_line.product_uom_qty > order_line.product_uom_max_qty:
|
if order_line.product_uom_qty > order_line.product_uom_max_qty:
|
||||||
raise UserError(
|
raise UserError(
|
||||||
_(
|
_(
|
||||||
f"{order_line.order_id.name},{order_line.product_id.name}:"
|
f"{order_line.order_id.name},{order_line.product_id.name}:"
|
||||||
|
|
@ -24,6 +24,9 @@ class SaleOrderLine(models.Model):
|
||||||
@api.model_create_multi
|
@api.model_create_multi
|
||||||
def create(self, vals_list):
|
def create(self, vals_list):
|
||||||
for vals in vals_list:
|
for vals in vals_list:
|
||||||
|
if not vals.get("product_uom_max_qty") or vals.get("product_uom_max_qty") == 0:
|
||||||
|
product_qty = vals.get("product_uom_qty")
|
||||||
|
vals["product_uom_max_qty"] = product_qty
|
||||||
if vals.get("product_id") and not vals.get("product_packaging_id"):
|
if vals.get("product_id") and not vals.get("product_packaging_id"):
|
||||||
product_id = vals.get("product_id")
|
product_id = vals.get("product_id")
|
||||||
packaging = self.env["product.packaging"].search([("product_id", "=", product_id)], limit=1)
|
packaging = self.env["product.packaging"].search([("product_id", "=", product_id)], limit=1)
|
||||||
|
|
|
||||||
|
|
@ -7,3 +7,7 @@
|
||||||
:1.3.1: add open_max_qty
|
:1.3.1: add open_max_qty
|
||||||
:1.3.2: fix color indicator
|
:1.3.2: fix color indicator
|
||||||
:1.3.3: Enable packagings on installation
|
:1.3.3: Enable packagings on installation
|
||||||
|
:1.3.4:
|
||||||
|
- 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
|
||||||
|
|
@ -391,23 +391,39 @@ and adds a packaging default to sale order batch.</p>
|
||||||
<col class="field-name" />
|
<col class="field-name" />
|
||||||
<col class="field-body" />
|
<col class="field-body" />
|
||||||
<tbody valign="top">
|
<tbody valign="top">
|
||||||
<tr class="field"><th class="field-name">0.0.1:</th><td class="field-body">Initial module.</td>
|
<tr class="field"><th class="field-name">0.0.1:</th><td class="field-body"><p class="first">Initial module.</p>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="field"><th class="field-name">1.0.0:</th><td class="field-body">rename to nfu_sale_order_batch_packaging</td>
|
<tr class="field"><th class="field-name">1.0.0:</th><td class="field-body"><p class="first">rename to nfu_sale_order_batch_packaging</p>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="field"><th class="field-name">1.1.0:</th><td class="field-body">Live</td>
|
<tr class="field"><th class="field-name">1.1.0:</th><td class="field-body"><p class="first">Live</p>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="field"><th class="field-name">1.2.0:</th><td class="field-body">Add regeneration action for batch products</td>
|
<tr class="field"><th class="field-name">1.2.0:</th><td class="field-body"><p class="first">Add regeneration action for batch products</p>
|
||||||
|
</td>
|
||||||
</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"><p class="first">refactoring</p>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="field"><th class="field-name">1.3.0:</th><td class="field-body">add packaging states</td>
|
<tr class="field"><th class="field-name">1.3.0:</th><td class="field-body"><p class="first">add packaging states</p>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="field"><th class="field-name">1.3.1:</th><td class="field-body">add open_max_qty</td>
|
<tr class="field"><th class="field-name">1.3.1:</th><td class="field-body"><p class="first">add open_max_qty</p>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="field"><th class="field-name">1.3.2:</th><td class="field-body">fix color indicator</td>
|
<tr class="field"><th class="field-name">1.3.2:</th><td class="field-body"><p class="first">fix color indicator</p>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="field"><th class="field-name">1.3.3:</th><td class="field-body">Enable packagings on installation</td>
|
<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">
|
||||||
|
<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>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class SaleOrderBatchProduct(models.Model):
|
||||||
def _compute_product_packaging_id(self):
|
def _compute_product_packaging_id(self):
|
||||||
for line in self:
|
for line in self:
|
||||||
# remove packaging if not match the product
|
# remove packaging if not match the product
|
||||||
if line.product_packaging_id.product_id != line.product_id:
|
if line.product_packaging_id and line.product_packaging_id.product_id != line.product_id:
|
||||||
line.product_packaging_id = False
|
line.product_packaging_id = False
|
||||||
# suggest always the first packaging
|
# suggest always the first packaging
|
||||||
if line.product_id and line.product_uom_qty and line.product_uom:
|
if line.product_id and line.product_uom_qty and line.product_uom:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue