mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
update sale weight
This commit is contained in:
@@ -2,19 +2,21 @@
|
|||||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'App Sales Order Weight',
|
'name': 'App Product Weight in Sales Order',
|
||||||
'version': '12.0.11.26',
|
'version': '12.0.11.26',
|
||||||
'summary': 'Add sku weight in Sale Order',
|
'summary': 'Add Product sku weight in Sale Order, product weight, sale weight, total weight',
|
||||||
'sequence': 10,
|
'sequence': 10,
|
||||||
'license': 'LGPL-3',
|
'license': 'LGPL-3',
|
||||||
'description': """
|
'description': """
|
||||||
Add sku weight in Sale Order.
|
Add product sku weight in Sale Order.
|
||||||
Calculates total weight of a sale order, which is the sum of individual weights of each unit of the products in the order
|
Calculates total weight of a sale order, which is the sum of individual weights of each unit of the products in the order
|
||||||
""",
|
""",
|
||||||
'category': 'Sales',
|
'category': 'Sales',
|
||||||
'author': 'Sunpop.cn',
|
'author': 'Sunpop.cn',
|
||||||
'website': 'http://www.sunpop.cn',
|
'website': 'http://www.sunpop.cn',
|
||||||
'images': ['static/description/banner.jpg'],
|
'images': ['static/description/banner.jpg'],
|
||||||
|
'currency': 'EUR',
|
||||||
|
'price': 38,
|
||||||
'depends': ['sale_management'],
|
'depends': ['sale_management'],
|
||||||
'data': [
|
'data': [
|
||||||
'views/sale_order_views.xml',
|
'views/sale_order_views.xml',
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ msgid "<span> kg</span>"
|
|||||||
msgstr "<span> 公斤</span>"
|
msgstr "<span> 公斤</span>"
|
||||||
|
|
||||||
#. module: app_product_weight_sale
|
#. module: app_product_weight_sale
|
||||||
#: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order_total_weight
|
#: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order_weight_total
|
||||||
msgid "Total Weight(kg)"
|
msgid "Total Weight(kg)"
|
||||||
msgstr "总重量(kg)"
|
msgstr "总重量(kg)"
|
||||||
|
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ from odoo import api, fields, models, _
|
|||||||
class SaleOrder(models.Model):
|
class SaleOrder(models.Model):
|
||||||
_inherit = "sale.order"
|
_inherit = "sale.order"
|
||||||
|
|
||||||
total_weight = fields.Float(string='Total Weight(kg)', compute='_compute_weight_total')
|
weight_total = fields.Float(string='Total Weight(kg)', compute='_compute_weight_total')
|
||||||
|
|
||||||
def _compute_weight_total(self):
|
def _compute_weight_total(self):
|
||||||
for sale in self:
|
for sale in self:
|
||||||
weight_tot = 0
|
weight_tot = 0
|
||||||
for line in sale.order_line:
|
for line in sale.order_line:
|
||||||
if line.product_id:
|
if line.product_id:
|
||||||
weight_tot += line.weight or 0.0
|
weight_tot += line.weight_subtotal or 0.0
|
||||||
sale.total_weight = weight_tot
|
sale.weight_total = weight_tot
|
||||||
|
|
||||||
|
|||||||
@@ -9,12 +9,13 @@ from odoo import api, fields, models, _
|
|||||||
class SaleOrderLine(models.Model):
|
class SaleOrderLine(models.Model):
|
||||||
_inherit = 'sale.order.line'
|
_inherit = 'sale.order.line'
|
||||||
|
|
||||||
weight = fields.Float(string='Weight(kg)', compute='_compute_weight',
|
weight = fields.Float(string='Weight', store=True)
|
||||||
inverse='_set_weight', store=True)
|
weight_subtotal = fields.Float(string='Weight Subtotal', compute='_compute_weight_subtotal',
|
||||||
|
inverse='_set_weight_subtotal', store=True)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.depends('product_id', 'product_uom_qty')
|
@api.depends('product_id', 'product_uom_qty')
|
||||||
def _compute_weight(self):
|
def _compute_weight_subtotal(self):
|
||||||
for line in self:
|
for line in self:
|
||||||
weight = 0
|
weight = 0
|
||||||
if line.product_id and line.product_id.weight:
|
if line.product_id and line.product_id.weight:
|
||||||
@@ -22,5 +23,5 @@ class SaleOrderLine(models.Model):
|
|||||||
line.weight = weight
|
line.weight = weight
|
||||||
|
|
||||||
@api.one
|
@api.one
|
||||||
def _set_weight(self):
|
def _set_weight_subtotal(self):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ The calculation uses the following formula:
|
|||||||
<p class='oe_mt32'>
|
<p class='oe_mt32'>
|
||||||
Sale_order_line_net_weight = (line_product_weight * line_product_uom_qty / line_product_uom_factor)
|
Sale_order_line_net_weight = (line_product_weight * line_product_uom_qty / line_product_uom_factor)
|
||||||
<br/>
|
<br/>
|
||||||
Total_weight = sum(Sale_order_line_net_weight)
|
weight_total = sum(Sale_order_line_net_weight)
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<field name="inherit_id" ref="sale.view_order_tree"/>
|
<field name="inherit_id" ref="sale.view_order_tree"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//field[@name='state']" position="after">
|
<xpath expr="//field[@name='state']" position="after">
|
||||||
<field name="total_weight"/>
|
<field name="weight_total"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<field name="inherit_id" ref="sale.view_quotation_tree"/>
|
<field name="inherit_id" ref="sale.view_quotation_tree"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//field[@name='state']" position="after">
|
<xpath expr="//field[@name='state']" position="after">
|
||||||
<field name="total_weight"/>
|
<field name="weight_total"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -34,8 +34,8 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//field[@name='note']" position="before">
|
<xpath expr="//field[@name='note']" position="before">
|
||||||
<div>
|
<div>
|
||||||
<label for="total_weight" name="total_weight" string="Total Weight: " class="oe_inline"/>
|
<label for="weight_total" name="weight_total" string="Total Weight: " class="oe_inline"/>
|
||||||
<field name="total_weight" class="oe_inline"/><span> kg</span>
|
<field name="weight_total" class="oe_inline"/><span> kg</span>
|
||||||
</div>
|
</div>
|
||||||
<newline/>
|
<newline/>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|||||||
Reference in New Issue
Block a user