[fix] string cosmetics and formating

This commit is contained in:
Niels Göttsch 2024-07-23 21:25:28 +02:00
parent b8991d6b2b
commit 7e0e9e5862
4 changed files with 7 additions and 8 deletions

View file

@ -10,9 +10,7 @@ class SaleOrderBatchProduct(models.Model):
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")) sum(product.sale_order_line_ids.mapped("product_uom_qty")) % product.product_packaging_qty
% product.product_packaging_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

View file

@ -5,7 +5,7 @@
<field name="model">sale.order.batch.product</field> <field name="model">sale.order.batch.product</field>
<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="//field[@name='batch_id']" position="after"> <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_qty != 0)"/>
</xpath> </xpath>
<xpath <xpath

View file

@ -26,7 +26,7 @@ class SaleOrderBatchProduct(models.Model):
"sale.order.line", compute="_compute_sale_order_line_ids", store=True, readonly=False "sale.order.line", compute="_compute_sale_order_line_ids", store=True, readonly=False
) )
product_uom_category_id = fields.Many2one(related="product_id.uom_id.category_id", depends=["product_id"]) 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_qty = fields.Float(compute="_compute_uom_qty", string="Quantity")
product_uom = fields.Many2one(related="product_id.uom_id") product_uom = fields.Many2one(related="product_id.uom_id")
product_packaging_id = fields.Many2one("product.packaging") product_packaging_id = fields.Many2one("product.packaging")
product_packaging_qty = fields.Float(compute="_compute_product_packaging_qty") product_packaging_qty = fields.Float(compute="_compute_product_packaging_qty")
@ -38,7 +38,7 @@ class SaleOrderBatchProduct(models.Model):
lambda o: o.product_id == product.product_id lambda o: o.product_id == product.product_id
) )
@api.depends("batch_id.sale_order_line_ids") @api.depends("sale_order_line_ids.product_uom_qty")
def _compute_uom_qty(self): def _compute_uom_qty(self):
for product in self: for product in self:
product.product_uom_qty = sum(product.sale_order_line_ids.mapped("product_uom_qty")) product.product_uom_qty = sum(product.sale_order_line_ids.mapped("product_uom_qty"))

View file

@ -12,10 +12,11 @@
<field name="product_id"/> <field name="product_id"/>
</h1> </h1>
<group> <group>
<group> <group name="product_info">
<field name="batch_id"/> <field name="batch_id"/>
<field name="product_uom_qty"/>
</group> </group>
<group> <group name="packaging_info">
<field name="product_packaging_id"/> <field name="product_packaging_id"/>
<field name="product_packaging_qty"/> <field name="product_packaging_qty"/>
</group> </group>