diff --git a/app_product_weight_sale/__manifest__.py b/app_product_weight_sale/__manifest__.py index d0759d06..2b86f317 100644 --- a/app_product_weight_sale/__manifest__.py +++ b/app_product_weight_sale/__manifest__.py @@ -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', ], diff --git a/app_product_weight_sale/i18n/zh_CN.po b/app_product_weight_sale/i18n/zh_CN.po index b0a0dd49..f87ea35d 100644 --- a/app_product_weight_sale/i18n/zh_CN.po +++ b/app_product_weight_sale/i18n/zh_CN.po @@ -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 " kg" -msgstr " 公斤" +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 "产品重量、包装不包括在内。可以在一般设置中改变测量单位。" diff --git a/app_product_weight_sale/models/sale_order.py b/app_product_weight_sale/models/sale_order.py index 9f4818bf..bf347fd7 100644 --- a/app_product_weight_sale/models/sale_order.py +++ b/app_product_weight_sale/models/sale_order.py @@ -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 diff --git a/app_product_weight_sale/models/sale_order_line.py b/app_product_weight_sale/models/sale_order_line.py index 31e3ba86..b91f3e56 100644 --- a/app_product_weight_sale/models/sale_order_line.py +++ b/app_product_weight_sale/models/sale_order_line.py @@ -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 diff --git a/app_product_weight_sale/static/description/banner.jpg b/app_product_weight_sale/static/description/banner.jpg index c064ed42..e3de4f89 100644 Binary files a/app_product_weight_sale/static/description/banner.jpg and b/app_product_weight_sale/static/description/banner.jpg differ diff --git a/app_product_weight_sale/static/description/banner.png b/app_product_weight_sale/static/description/banner.png new file mode 100644 index 00000000..205ef176 Binary files /dev/null and b/app_product_weight_sale/static/description/banner.png differ diff --git a/app_product_weight_sale/static/description/demo1.jpg b/app_product_weight_sale/static/description/demo1.jpg new file mode 100644 index 00000000..c064ed42 Binary files /dev/null and b/app_product_weight_sale/static/description/demo1.jpg differ diff --git a/app_product_weight_sale/static/description/index.html b/app_product_weight_sale/static/description/index.html index 8a244b65..00adfd61 100644 --- a/app_product_weight_sale/static/description/index.html +++ b/app_product_weight_sale/static/description/index.html @@ -3,32 +3,46 @@

Sales Order Weight

+
+ Key features: + +

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

-

-The product form has a field 'Weight', which stores the weight of the product in Kg. -

+

- +

+ Setup product weight. +

+
- -

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

-
- +

+ Get product weight and total weight in order. +

+
-

-The calculation uses the following formula: -

+

+ The calculation uses the following formula: +

-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)
-Total_weight = sum(Sale_order_line_net_weight) +weight_total = sum(order_line_net_weight)

diff --git a/app_product_weight_sale/views/sale_order_views.xml b/app_product_weight_sale/views/sale_order_views.xml index 90bfb434..5aa8a469 100644 --- a/app_product_weight_sale/views/sale_order_views.xml +++ b/app_product_weight_sale/views/sale_order_views.xml @@ -8,8 +8,8 @@ sale.order - - + + @@ -19,8 +19,8 @@ sale.order - - + + @@ -34,16 +34,18 @@
-
+ - + +