mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
add pr weight
This commit is contained in:
@@ -38,7 +38,7 @@ msgstr "总重量"
|
||||
#. module: app_product_weight_sale
|
||||
#: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order_line__weight
|
||||
msgid "Weight"
|
||||
msgstr "重量"
|
||||
msgstr "单位重量"
|
||||
|
||||
#. module: app_product_weight_sale
|
||||
#: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order__weight_uom_name
|
||||
|
||||
@@ -15,7 +15,7 @@ class SaleOrder(models.Model):
|
||||
else:
|
||||
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)
|
||||
|
||||
|
||||
@@ -15,14 +15,14 @@ class SaleOrderLine(models.Model):
|
||||
weight_subtotal = fields.Float(string='Weight Subtotal', compute='_compute_weight', store=True)
|
||||
|
||||
@api.multi
|
||||
@api.depends('product_id', 'product_uom', 'product_qty')
|
||||
@api.depends('product_id', 'product_uom', 'product_uom_qty')
|
||||
def _compute_weight(self):
|
||||
for line in self:
|
||||
weight = 0
|
||||
weight_subtotal = 0
|
||||
if line.product_id and line.product_id.weight:
|
||||
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_subtotal = weight_subtotal
|
||||
|
||||
|
||||
BIN
app_product_weight_sale/static/description/demo2.jpg
Normal file
BIN
app_product_weight_sale/static/description/demo2.jpg
Normal file
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 |
@@ -29,6 +29,13 @@
|
||||
<img class="oe_screenshot" src="product_weight.jpg">
|
||||
</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">
|
||||
<h3 class='oe_mt32'>
|
||||
Get product weight and total weight in order.
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<field name="inherit_id" ref="sale.view_order_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='amount_total']" position="before">
|
||||
<field name="weight_total"/>
|
||||
<field name="weight_total" sum="Total Weight"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
@@ -20,7 +20,7 @@
|
||||
<field name="inherit_id" ref="sale.view_quotation_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='amount_total']" position="before">
|
||||
<field name="weight_total"/>
|
||||
<field name="weight_total" sum="Total Weight"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
@@ -39,7 +39,7 @@
|
||||
</div>
|
||||
<newline/>
|
||||
</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_subtotal"/>
|
||||
</xpath>
|
||||
|
||||
Reference in New Issue
Block a user