add pr weight

This commit is contained in:
ivan deng
2019-01-03 18:30:39 +08:00
parent fe96ebd665
commit bbde892a4f
7 changed files with 14 additions and 7 deletions

View File

@@ -38,7 +38,7 @@ msgstr "总重量"
#. module: app_product_weight_sale #. module: app_product_weight_sale
#: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order_line__weight #: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order_line__weight
msgid "Weight" msgid "Weight"
msgstr "重量" msgstr "单位重量"
#. module: app_product_weight_sale #. module: app_product_weight_sale
#: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order__weight_uom_name #: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order__weight_uom_name

View File

@@ -15,7 +15,7 @@ class SaleOrder(models.Model):
else: else:
return self.env.ref('uom.product_uom_kgm').name return self.env.ref('uom.product_uom_kgm').name
weight_total = fields.Float(string='Total Weight', compute='_compute_weight_total', store=True) weight_total = fields.Float(string='Total Weight', compute='_compute_weight_total')
# 重量显示的单位 # 重量显示的单位
weight_uom_name = fields.Char(string='Weight Measure', default=_get_default_weight_uom_name, readonly=True) weight_uom_name = fields.Char(string='Weight Measure', default=_get_default_weight_uom_name, readonly=True)

View File

@@ -15,14 +15,14 @@ class SaleOrderLine(models.Model):
weight_subtotal = fields.Float(string='Weight Subtotal', compute='_compute_weight', store=True) weight_subtotal = fields.Float(string='Weight Subtotal', compute='_compute_weight', store=True)
@api.multi @api.multi
@api.depends('product_id', 'product_uom', 'product_qty') @api.depends('product_id', 'product_uom', 'product_uom_qty')
def _compute_weight(self): def _compute_weight(self):
for line in self: for line in self:
weight = 0 weight = 0
weight_subtotal = 0 weight_subtotal = 0
if line.product_id and line.product_id.weight: if line.product_id and line.product_id.weight:
weight = line.product_id.weight / line.product_uom.factor weight = line.product_id.weight / line.product_uom.factor
weight_subtotal += (weight * line.product_qty) weight_subtotal += (weight * line.product_uom_qty)
line.weight = weight line.weight = weight
line.weight_subtotal = weight_subtotal line.weight_subtotal = weight_subtotal

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 135 KiB

View File

@@ -29,6 +29,13 @@
<img class="oe_screenshot" src="product_weight.jpg"> <img class="oe_screenshot" src="product_weight.jpg">
</div> </div>
<div class="oe_demo oe_screenshot">
<h3 class='oe_mt32'>
Show product total weight in list view.
</h3>
<img class="oe_screenshot" src="demo2.jpg">
</div>
<div class="oe_demo oe_screenshot"> <div class="oe_demo oe_screenshot">
<h3 class='oe_mt32'> <h3 class='oe_mt32'>
Get product weight and total weight in order. Get product weight and total weight in order.

View File

@@ -9,7 +9,7 @@
<field name="inherit_id" ref="sale.view_order_tree"/> <field name="inherit_id" ref="sale.view_order_tree"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='amount_total']" position="before"> <xpath expr="//field[@name='amount_total']" position="before">
<field name="weight_total"/> <field name="weight_total" sum="Total Weight"/>
</xpath> </xpath>
</field> </field>
</record> </record>
@@ -20,7 +20,7 @@
<field name="inherit_id" ref="sale.view_quotation_tree"/> <field name="inherit_id" ref="sale.view_quotation_tree"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='amount_total']" position="before"> <xpath expr="//field[@name='amount_total']" position="before">
<field name="weight_total"/> <field name="weight_total" sum="Total Weight"/>
</xpath> </xpath>
</field> </field>
</record> </record>
@@ -39,7 +39,7 @@
</div> </div>
<newline/> <newline/>
</xpath> </xpath>
<xpath expr="//field[@name='order_line']/tree/field[@name='product_uom']" position="after"> <xpath expr="//field[@name='order_line']/tree//field[@name='product_uom']" position="after">
<field name="weight"/> <field name="weight"/>
<field name="weight_subtotal"/> <field name="weight_subtotal"/>
</xpath> </xpath>