[add] unfinisched packages warning

This commit is contained in:
Niels Göttsch 2024-07-21 01:25:19 +02:00
parent 4569ce9655
commit 46bf4d5c1a
8 changed files with 76 additions and 6 deletions

2
.vscode/launch.json vendored
View file

@ -13,7 +13,7 @@
"--addons-path=${config:odoo.addons_path},${workspaceFolder}",
"--limit-time-real=0",
"--limit-time-cpu=0",
"--init=sale_order_batch",
"--update=sale_order_batch,nfu_sale_order_packaging",
// "--update=",
"--dev=xml"
]

View file

@ -6,6 +6,10 @@
"category": "Stock",
"version": "16.0.0.0.1",
"depends": ["sale", "sale_order_batch"],
"data": ["views/sale_order_views.xml", "views/sale_order_batch_views.xml"],
"data": [
"views/sale_order_views.xml",
"views/sale_order_batch_views.xml",
"views/sale_order_batch_product_views.xml",
],
"license": "LGPL-3",
}

View file

@ -1,9 +1,18 @@
from odoo import api, models
from odoo import api, fields, models
class SaleOrderBatchProduct(models.Model):
_inherit = "sale.order.batch.product"
open_packaging_qty = fields.Float(compute="_compute_open_packagin_qty")
@api.depends("sale_order_line_ids.product_uom_qty")
def _compute_open_packagin_qty(self):
for product in self:
product.open_packaging_qty = (
sum(product.sale_order_line_ids.mapped("product_uom_qty")) % product.product_packaging_qty
)
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_order_batch_product_form" model="ir.ui.view">
<field name="name">sale.order.batch.product.form.nfu</field>
<field name="model">sale.order.batch.product</field>
<field name="inherit_id" ref="sale_order_batch.view_order_batch_product_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='batch_id']" position="after">
<field name="open_packaging_qty" decoration-warning="(open_packaging_qty != 0)"/>
</xpath>
</field>
</record>
</odoo>

View file

@ -9,6 +9,7 @@
"data": [
"data/ir_sequence_data.xml",
"views/sale_order_batch_views.xml",
"views/sale_order_batch_product_views.xml",
"views/sale_order_views.xml",
"views/sale_menus.xml",
"security/ir.model.access.csv",

View file

@ -14,14 +14,15 @@ class SaleOrderBatchProduct(models.Model):
ondelete="cascade",
index=True,
copy=False,
readonly=True,
)
product_id = fields.Many2one(comodel_name="product.product", required=True, readonly=False)
product_id = fields.Many2one(comodel_name="product.product", required=True, readonly=True)
product_template_id = fields.Many2one(
"product.template", related="product_id.product_tmpl_id", string="Product Template"
)
sale_order_line_ids = fields.Many2many("sale.order.line", compute="_compute_sale_order_line_ids")
sale_order_line_ids = fields.Many2many("sale.order.line", compute="_compute_sale_order_line_ids", store=True)
product_uom_category_id = fields.Many2one(related="product_id.uom_id.category_id", depends=["product_id"])
product_uom_qty = fields.Float(compute="_compute_uom_qty")
product_uom = fields.Many2one(related="product_id.uom_id")

View file

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="view_order_batch_product_form" model="ir.ui.view">
<field name="name">sale.order.batch.product.form</field>
<field name="model">sale.order.batch.product</field>
<field name="arch" type="xml">
<form>
<sheet>
<div class="oe_button_box" name="button_box">
</div>
<h1>
<field name="product_id"/>
</h1>
<group>
<group>
<field name="batch_id"/>
</group>
<group>
<field name="product_packaging_id"/>
<field name="product_packaging_qty"/>
</group>
</group>
<notebook>
<page string="Sale Order Lines" name="order_line">
<field name="sale_order_line_ids" widget="section_and_note_one2many">
<tree editable="bottom">
<field name="sequence" widget="handle"/>
<field name="order_partner_id"/>
<field name="product_template_id"/>
<field name="name"/>
<field name="product_uom_qty"/>
<field name="price_unit"/>
<field name="price_subtotal"/>
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
</odoo>

View file

@ -106,7 +106,7 @@
</page>
<page string="Products" name="products">
<field name="product_ids">
<tree create="0" editable="1">
<tree create="0">
<field name="product_template_id"/>
<field name="product_uom_qty"/>
<field name="product_packaging_qty" groups="product.group_stock_packaging"/>