mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
update all weight
This commit is contained in:
@@ -4,10 +4,10 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 12.0+e-20181221\n"
|
||||
"Project-Id-Version: Odoo Server 12.0+e-20190124\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-01-02 15:10+0000\n"
|
||||
"PO-Revision-Date: 2019-01-02 15:10+0000\n"
|
||||
"POT-Creation-Date: 2019-01-28 10:38+0000\n"
|
||||
"PO-Revision-Date: 2019-01-28 10:38+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@@ -26,7 +26,9 @@ msgid "Sales Order Line"
|
||||
msgstr "销售订单行"
|
||||
|
||||
#. module: app_product_weight_sale
|
||||
#: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order__weight_total
|
||||
#: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order__weight
|
||||
#: model_terms:ir.ui.view,arch_db:app_product_weight_sale.sale_quotation_weight_tree
|
||||
#: model_terms:ir.ui.view,arch_db:app_product_weight_sale.sale_weight_tree
|
||||
msgid "Total Weight"
|
||||
msgstr "总重量"
|
||||
|
||||
@@ -35,23 +37,18 @@ msgstr "总重量"
|
||||
msgid "Total Weight:"
|
||||
msgstr "总重量"
|
||||
|
||||
#. module: app_product_weight_sale
|
||||
#: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order_line__weight
|
||||
msgid "Weight"
|
||||
msgstr "单位重量"
|
||||
|
||||
#. module: app_product_weight_sale
|
||||
#: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order__weight_uom_name
|
||||
msgid "Weight Measure"
|
||||
msgstr "重量单位名"
|
||||
msgstr "重量单位"
|
||||
|
||||
#. module: app_product_weight_sale
|
||||
#: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order_line__weight_subtotal
|
||||
#: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order_line__weight
|
||||
msgid "Weight Subtotal"
|
||||
msgstr "重量小计"
|
||||
|
||||
#. module: app_product_weight_sale
|
||||
#: model:ir.model.fields,help:app_product_weight_sale.field_sale_order_line__weight
|
||||
msgid "Weight of the product, packaging not included. The unit of measure can be changed in the general settings"
|
||||
msgstr "产品重量、包装不包括在内。可以在一般设置中改变测量单位。"
|
||||
#: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order_line__weight_unit
|
||||
msgid "Weight Unit"
|
||||
msgstr "单位重量"
|
||||
|
||||
|
||||
@@ -15,15 +15,17 @@ 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')
|
||||
weight = fields.Float(string='Total Weight', compute='_compute_weight')
|
||||
# 重量显示的单位
|
||||
weight_uom_name = fields.Char(string='Weight Measure', default=_get_default_weight_uom_name, readonly=True)
|
||||
|
||||
def _compute_weight_total(self):
|
||||
@api.multi
|
||||
@api.depends('order_line.weight')
|
||||
def _compute_weight(self):
|
||||
for rec in self:
|
||||
weight_tot = 0
|
||||
for line in rec.order_line:
|
||||
if line.product_id:
|
||||
weight_tot += line.weight_subtotal or 0.0
|
||||
rec.weight_total = weight_tot
|
||||
weight_tot += line.weight or 0.0
|
||||
rec.weight = weight_tot
|
||||
|
||||
|
||||
@@ -11,23 +11,22 @@ class SaleOrderLine(models.Model):
|
||||
|
||||
# 显示的单位,影响性能暂时不使用
|
||||
# weight_uom_name = fields.Char(string='Weight Measure', related='product_id.weight_uom_id.name', readonly=True)
|
||||
weight = fields.Float(string='Weight', compute='_compute_weight', store=True)
|
||||
weight_subtotal = fields.Float(string='Weight Subtotal', compute='_compute_weight', store=True)
|
||||
# 调整,根据 delivery 模块,将 weight 作为 该行合计,weight_unit 作为该单位的
|
||||
weight_unit = fields.Float(string='Weight Unit', compute='_compute_weight', store=True)
|
||||
weight = fields.Float(string='Weight Subtotal', compute='_compute_weight', store=True)
|
||||
|
||||
@api.multi
|
||||
@api.depends('product_id', 'product_uom', 'product_uom_qty')
|
||||
def _compute_weight(self):
|
||||
for line in self:
|
||||
for line in self.filtered(lambda rec: rec.product_id.weight > 0.00):
|
||||
weight = 0
|
||||
weight_subtotal = 0
|
||||
if line.product_id and line.product_id.weight:
|
||||
try:
|
||||
weight = line.product_id.weight / line.product_uom.factor
|
||||
except:
|
||||
weight = line.product_id.weight
|
||||
weight_subtotal += (weight * line.product_uom_qty)
|
||||
try:
|
||||
weight_unit = line.product_id.weight / line.product_uom.factor
|
||||
except:
|
||||
weight_unit = line.product_id.weight
|
||||
weight += (weight_unit * line.product_uom_qty)
|
||||
line.weight_unit = weight_unit
|
||||
line.weight = weight
|
||||
line.weight_subtotal = weight_subtotal
|
||||
|
||||
@api.one
|
||||
def _set_weight_subtotal(self):
|
||||
|
||||
@@ -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" sum="Total Weight"/>
|
||||
<field name="weight" 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" sum="Total Weight"/>
|
||||
<field name="weight" sum="Total Weight"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
@@ -34,18 +34,18 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='note']" position="before">
|
||||
<div>
|
||||
<label for="weight_total" name="weight_total" string="Total Weight: " class="oe_inline"/>
|
||||
<field name="weight_total" class="oe_inline"/><span> <field name="weight_uom_name" class="oe_inline"/></span>
|
||||
<label for="weight" name="weight" string="Total Weight: " class="oe_inline"/>
|
||||
<field name="weight" class="oe_inline"/><span> <field name="weight_uom_name" class="oe_inline"/></span>
|
||||
</div>
|
||||
<newline/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='order_line']/tree//field[@name='product_uom']" position="after">
|
||||
<field name="weight_unit" invisible="1"/>
|
||||
<field name="weight"/>
|
||||
<field name="weight_subtotal"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='order_line']/form//field[@name='price_unit']" position="before">
|
||||
<field name="weight"/>
|
||||
<field name="weight_subtotal"/>
|
||||
<field name="weight_unit" invisible="1"/>
|
||||
<field name="weight"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user