diff --git a/app_product_weight_sale/__manifest__.py b/app_product_weight_sale/__manifest__.py
index 5a699209..5ad48ea6 100644
--- a/app_product_weight_sale/__manifest__.py
+++ b/app_product_weight_sale/__manifest__.py
@@ -2,7 +2,7 @@
{
'name': 'Weight in Sales Order',
- 'version': '12.19.04.16',
+ 'version': '12.19.06.10',
'summary': 'Add Product sku weight in Sale Order, product weight, sale weight, sale order weight, total weight, kg kg(s) lb lb(s) support',
'sequence': 10,
'license': 'LGPL-3',
diff --git a/app_product_weight_sale/models/sale_order_line.py b/app_product_weight_sale/models/sale_order_line.py
index 53ac7b22..e8d5a4c1 100644
--- a/app_product_weight_sale/models/sale_order_line.py
+++ b/app_product_weight_sale/models/sale_order_line.py
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
+from odoo.addons import decimal_precision as dp
+
from odoo import api, fields, models, _
@@ -11,7 +13,8 @@ class SaleOrderLine(models.Model):
# 显示的单位,影响性能暂时不使用
# weight_uom_name = fields.Char(string='Weight Measure', related='product_id.weight_uom_id.name', readonly=True)
# 调整,根据 delivery 模块,将 weight 作为 该行合计,weight_unit 作为该单位的
- weight_unit = fields.Float(string='Weight Unit', compute='_compute_weight', store=True)
+ weight_unit = fields.Float(string='Weight Unit', compute='_compute_weight', digits=dp.get_precision('Stock Weight'),
+ inverse='_set_weight', store=True)
weight = fields.Float(string='Weight Subtotal', compute='_compute_weight', store=True)
@api.multi
@@ -30,3 +33,11 @@ class SaleOrderLine(models.Model):
@api.one
def _set_weight_subtotal(self):
pass
+
+ @api.one
+ def _set_weight(self):
+ if self.weight_unit and self.weight_unit > 0:
+ try:
+ self.product_id.weight = self.weight_unit * self.product_uom.factor
+ except:
+ self.product_id.weight = self.weight_unit
diff --git a/app_product_weight_sale/views/sale_order_views.xml b/app_product_weight_sale/views/sale_order_views.xml
index 17506373..b4699e46 100644
--- a/app_product_weight_sale/views/sale_order_views.xml
+++ b/app_product_weight_sale/views/sale_order_views.xml
@@ -40,11 +40,11 @@
-
+
-
+