update weight of sale

This commit is contained in:
ivan deng
2019-06-17 16:32:28 +08:00
parent 28f3cb44d0
commit ac4a5b3f92
3 changed files with 15 additions and 4 deletions

View File

@@ -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',

View File

@@ -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

View File

@@ -40,11 +40,11 @@
<newline/>
</xpath>
<xpath expr="//field[@name='order_line']/tree//field[@name='product_uom']" position="after">
<field name="weight_unit" invisible="1"/>
<field name="weight_unit"/>
<field name="weight"/>
</xpath>
<xpath expr="//field[@name='order_line']/form//field[@name='price_unit']" position="before">
<field name="weight_unit" invisible="1"/>
<field name="weight_unit"/>
<field name="weight"/>
</xpath>
</field>