diff --git a/app_product_weight_sale/i18n/zh_CN.po b/app_product_weight_sale/i18n/zh_CN.po
index e8bc69d8..afa423f5 100644
--- a/app_product_weight_sale/i18n/zh_CN.po
+++ b/app_product_weight_sale/i18n/zh_CN.po
@@ -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 "单位重量"
diff --git a/app_product_weight_sale/models/sale_order.py b/app_product_weight_sale/models/sale_order.py
index bf347fd7..bb56e9e2 100644
--- a/app_product_weight_sale/models/sale_order.py
+++ b/app_product_weight_sale/models/sale_order.py
@@ -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
diff --git a/app_product_weight_sale/models/sale_order_line.py b/app_product_weight_sale/models/sale_order_line.py
index 3c0157cd..026d5cf6 100644
--- a/app_product_weight_sale/models/sale_order_line.py
+++ b/app_product_weight_sale/models/sale_order_line.py
@@ -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):
diff --git a/app_product_weight_sale/views/sale_order_views.xml b/app_product_weight_sale/views/sale_order_views.xml
index f626ca6a..17506373 100644
--- a/app_product_weight_sale/views/sale_order_views.xml
+++ b/app_product_weight_sale/views/sale_order_views.xml
@@ -9,7 +9,7 @@
-
+
@@ -20,7 +20,7 @@
-
+
@@ -34,18 +34,18 @@
-
-
+
+
+
-
-
-
+
+