mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
update weight of sale
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Weight in Sales Order',
|
'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',
|
'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,
|
'sequence': 10,
|
||||||
'license': 'LGPL-3',
|
'license': 'LGPL-3',
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
from odoo.addons import decimal_precision as dp
|
||||||
|
|
||||||
from odoo import api, fields, models, _
|
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)
|
# weight_uom_name = fields.Char(string='Weight Measure', related='product_id.weight_uom_id.name', readonly=True)
|
||||||
# 调整,根据 delivery 模块,将 weight 作为 该行合计,weight_unit 作为该单位的
|
# 调整,根据 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)
|
weight = fields.Float(string='Weight Subtotal', compute='_compute_weight', store=True)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@@ -30,3 +33,11 @@ class SaleOrderLine(models.Model):
|
|||||||
@api.one
|
@api.one
|
||||||
def _set_weight_subtotal(self):
|
def _set_weight_subtotal(self):
|
||||||
pass
|
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
|
||||||
|
|||||||
@@ -40,11 +40,11 @@
|
|||||||
<newline/>
|
<newline/>
|
||||||
</xpath>
|
</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_unit" invisible="1"/>
|
<field name="weight_unit"/>
|
||||||
<field name="weight"/>
|
<field name="weight"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//field[@name='order_line']/form//field[@name='price_unit']" position="before">
|
<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"/>
|
<field name="weight"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
Reference in New Issue
Block a user