mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
add purchase weight
This commit is contained in:
@@ -2,20 +2,23 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
{
|
||||
'name' : 'App Sales Order Weight',
|
||||
'version' : '11.1.7.21',
|
||||
'summary': 'Add sku weight in Sale Order',
|
||||
'name': 'App Product Weight in Sales Order',
|
||||
'version': '11.19.01.02',
|
||||
'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',
|
||||
'license': 'LGPL-3',
|
||||
'description': """
|
||||
Add 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
|
||||
Add product sku weight in Sale Order. Unit of measure auto weight, kg kg(s) lb lb(s) support.
|
||||
Calculates total weight of a sale order, which is the sum of individual weights of each unit of the products in the order。
|
||||
Support kg(s) or lb(s)
|
||||
""",
|
||||
'category': 'Sales',
|
||||
'author' : 'Sunpop.cn',
|
||||
'website' : 'http://www.sunpop.cn',
|
||||
'author': 'Sunpop.cn',
|
||||
'website': 'http://www.sunpop.cn',
|
||||
'images': ['static/description/banner.jpg'],
|
||||
'depends' : ['sale_management'],
|
||||
'currency': 'EUR',
|
||||
'price': 38,
|
||||
'depends': ['sale_management'],
|
||||
'data': [
|
||||
'views/sale_order_views.xml',
|
||||
],
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 11.0+e-20180617\n"
|
||||
"Project-Id-Version: Odoo Server 12.0+e-20181123\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-07-20 17:42+0000\n"
|
||||
"PO-Revision-Date: 2018-07-20 17:42+0000\n"
|
||||
"POT-Creation-Date: 2018-12-14 04:46+0000\n"
|
||||
"PO-Revision-Date: 2018-12-14 04:46+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@@ -16,22 +16,42 @@ msgstr ""
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: app_product_weight_sale
|
||||
#: model:ir.ui.view,arch_db:app_product_weight_sale.sale_weight_line_form
|
||||
#: model_terms:ir.ui.view,arch_db:app_product_weight_sale.sale_weight_line_form
|
||||
msgid "<span> kg</span>"
|
||||
msgstr "<span> 公斤</span>"
|
||||
msgstr ""
|
||||
|
||||
#. module: app_product_weight_sale
|
||||
#: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order_total_weight
|
||||
#: model:ir.model,name:app_product_weight_sale.model_sale_order
|
||||
msgid "Sale Order"
|
||||
msgstr "销售订单"
|
||||
|
||||
#. module: app_product_weight_sale
|
||||
#: model:ir.model,name:app_product_weight_sale.model_sale_order_line
|
||||
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
|
||||
msgid "Total Weight(kg)"
|
||||
msgstr "总重量(kg)"
|
||||
|
||||
#. module: app_product_weight_sale
|
||||
#: model:ir.ui.view,arch_db:app_product_weight_sale.sale_weight_line_form
|
||||
#: model_terms:ir.ui.view,arch_db:app_product_weight_sale.sale_weight_line_form
|
||||
msgid "Total Weight:"
|
||||
msgstr "总重量:"
|
||||
msgstr "总重量"
|
||||
|
||||
#. module: app_product_weight_sale
|
||||
#: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order_line_weight
|
||||
msgid "Weight(kg)"
|
||||
msgstr "公斤"
|
||||
#: 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_line__weight_subtotal
|
||||
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 "产品重量、包装不包括在内。可以在一般设置中改变测量单位。"
|
||||
|
||||
|
||||
@@ -7,13 +7,23 @@ from odoo import api, fields, models, _
|
||||
class SaleOrder(models.Model):
|
||||
_inherit = "sale.order"
|
||||
|
||||
total_weight = fields.Float(string='Total Weight(kg)', compute='_compute_weight_total')
|
||||
def _get_default_weight_uom_name(self):
|
||||
get_param = self.env['ir.config_parameter'].sudo().get_param
|
||||
product_weight_in_lbs_param = get_param('product.weight_in_lbs')
|
||||
if product_weight_in_lbs_param == '1':
|
||||
return self.env.ref('uom.product_uom_lb').name
|
||||
else:
|
||||
return self.env.ref('uom.product_uom_kgm').name
|
||||
|
||||
weight_total = fields.Float(string='Total Weight', compute='_compute_weight_total')
|
||||
# 重量显示的单位
|
||||
weight_uom_name = fields.Char(string='Weight Measure', default=_get_default_weight_uom_name, readonly=True)
|
||||
|
||||
def _compute_weight_total(self):
|
||||
for sale in self:
|
||||
for rec in self:
|
||||
weight_tot = 0
|
||||
for line in sale.order_line:
|
||||
for line in rec.order_line:
|
||||
if line.product_id:
|
||||
weight_tot += line.weight or 0.0
|
||||
sale.total_weight = weight_tot
|
||||
weight_tot += line.weight_subtotal or 0.0
|
||||
rec.weight_total = weight_tot
|
||||
|
||||
|
||||
@@ -9,18 +9,23 @@ from odoo import api, fields, models, _
|
||||
class SaleOrderLine(models.Model):
|
||||
_inherit = 'sale.order.line'
|
||||
|
||||
weight = fields.Float(string='Weight(kg)', compute='_compute_weight',
|
||||
inverse='_set_weight', store=True)
|
||||
# 显示的单位,影响性能暂时不使用
|
||||
# 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', readonly=True)
|
||||
weight_subtotal = fields.Float(string='Weight Subtotal', compute='_compute_weight', store=True)
|
||||
|
||||
@api.multi
|
||||
@api.depends('product_id', 'product_uom_qty')
|
||||
@api.depends('product_id', 'product_uom', 'product_qty')
|
||||
def _compute_weight(self):
|
||||
for line in self:
|
||||
weight = 0
|
||||
weight_subtotal = 0
|
||||
if line.product_id and line.product_id.weight:
|
||||
weight += (line.product_id.weight * line.product_uom_qty / line.product_uom.factor)
|
||||
weight = line.product_id.weight / line.product_uom.factor
|
||||
weight_subtotal += (weight * line.product_qty)
|
||||
line.weight = weight
|
||||
line.weight_subtotal = weight_subtotal
|
||||
|
||||
@api.one
|
||||
def _set_weight(self):
|
||||
def _set_weight_subtotal(self):
|
||||
pass
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 78 KiB |
BIN
app_product_weight_sale/static/description/banner.png
Normal file
BIN
app_product_weight_sale/static/description/banner.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 287 KiB |
BIN
app_product_weight_sale/static/description/demo1.jpg
Normal file
BIN
app_product_weight_sale/static/description/demo1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 74 KiB |
@@ -3,32 +3,46 @@
|
||||
<div class="oe_span12">
|
||||
<h2 class="oe_slogan">Sales Order Weight</h2>
|
||||
</div>
|
||||
<div class="alert alert-info" style="padding:8px;font-weight: 300; font-size: 20px;">
|
||||
<i class="fa fa-hand-o-right"></i><b> Key features: </b>
|
||||
<ul class="list-unstyled">
|
||||
<li>
|
||||
<i class="fa fa-check-square-o text-primary"></i>
|
||||
Add product sku weight in Sale Order line.
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-check-square-o text-primary"></i>
|
||||
Calculates total weight of a sale order, which is the sum of individual weights of each unit of the products in the order.
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-check-square-o text-primary"></i>
|
||||
Support kg(s) or lb(s)
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<p class='oe_mt32'>
|
||||
This module from BroadTech IT Solutions manages to calculate total weight of a sale order, which is the sum of individual weights of each unit of the products in the order.
|
||||
</p>
|
||||
<p class='oe_mt32'>
|
||||
The product form has a field 'Weight', which stores the weight of the product in Kg.
|
||||
</p>
|
||||
<div class="oe_demo oe_screenshot">
|
||||
<img class="oe_picture oe_screenshot" src="product_weight.jpg">
|
||||
<h3 class='oe_mt32'>
|
||||
Setup product weight.
|
||||
</h3>
|
||||
<img class="oe_screenshot" src="product_weight.jpg">
|
||||
</div>
|
||||
|
||||
|
||||
<p class='oe_span12 oe_mt32'>
|
||||
The module adds a field 'Net Weight' in sale order line, which calculates the Order line weight based on Order line Quantity and Unit of Measure. The new field 'Total Weight' in Sale Order would be the sum of sale order line weights.
|
||||
</p>
|
||||
|
||||
<div class="oe_demo oe_screenshot">
|
||||
<img class="oe_picture oe_screenshot" src="banner.jpg">
|
||||
<h3 class='oe_mt32'>
|
||||
Get product weight and total weight in order.
|
||||
</h3>
|
||||
<img class="oe_screenshot" src="demo1.jpg">
|
||||
</div>
|
||||
|
||||
<p class='oe_span12 oe_mt32'>
|
||||
The calculation uses the following formula:
|
||||
</p>
|
||||
The calculation uses the following formula:
|
||||
</p>
|
||||
<p class='oe_mt32'>
|
||||
Sale_order_line_net_weight = (line_product_weight * line_product_uom_qty / line_product_uom_factor)
|
||||
order_line_net_weight = (line_product_weight / line_product_uom_factor)
|
||||
<br/>
|
||||
Total_weight = sum(Sale_order_line_net_weight)
|
||||
weight_total = sum(order_line_net_weight)
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='state']" position="after">
|
||||
<field name="total_weight"/>
|
||||
<xpath expr="//field[@name='amount_total']" position="before">
|
||||
<field name="weight_total"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
@@ -19,8 +19,8 @@
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_quotation_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='state']" position="after">
|
||||
<field name="total_weight"/>
|
||||
<xpath expr="//field[@name='amount_total']" position="before">
|
||||
<field name="weight_total"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
@@ -34,16 +34,18 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='note']" position="before">
|
||||
<div>
|
||||
<label for="total_weight" name="total_weight" string="Total Weight: " class="oe_inline"/>
|
||||
<field name="total_weight" class="oe_inline"/><span> kg</span>
|
||||
<label for="weight_total" name="weight_total" string="Total Weight: " class="oe_inline"/>
|
||||
<field name="weight_total" class="oe_inline"/><span> <field name="weight_uom_name" class="oe_inline"/></span>
|
||||
</div>
|
||||
<newline/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='order_line']/tree/field[@name='product_uom']" position="after">
|
||||
<field name="weight"/>
|
||||
<field name="weight_subtotal"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='order_line']/form/group/group/field[@name='price_unit']" position="before">
|
||||
<xpath expr="//field[@name='order_line']/form//field[@name='price_unit']" position="before">
|
||||
<field name="weight"/>
|
||||
<field name="weight_subtotal"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user