diff --git a/app_sale_order_weight/__init__.py b/app_sale_order_weight/__init__.py new file mode 100644 index 00000000..95ef785c --- /dev/null +++ b/app_sale_order_weight/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import models + + diff --git a/app_sale_order_weight/__manifest__.py b/app_sale_order_weight/__manifest__.py new file mode 100644 index 00000000..f3927058 --- /dev/null +++ b/app_sale_order_weight/__manifest__.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 ---*--- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +{ + 'name' : 'App Sales Order Weight', + 'version' : '11.1.6.17', + 'summary': 'Add sku weight in Sale Order', + 'sequence': 10, + '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 + """, + 'category': 'Sales', + 'author' : 'Sunpop.cn', + 'website' : 'http://www.sunpop.cn', + 'images': ['static/description/banner.jpg'], + 'depends' : ['sale_management'], + 'data': [ + 'views/sale_order_views.xml', + ], + 'demo': [ + ], + 'qweb': [ + ], + 'installable': True, + 'application': True, + 'auto_install': False, +} diff --git a/app_sale_order_weight/i18n/zh_CN.po b/app_sale_order_weight/i18n/zh_CN.po new file mode 100644 index 00000000..15c8d7cc --- /dev/null +++ b/app_sale_order_weight/i18n/zh_CN.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * app_sale_order_weight +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0+e-20180429\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-06-17 15:47+0000\n" +"PO-Revision-Date: 2018-06-17 15:47+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: app_sale_order_weight +#: model:ir.ui.view,arch_db:app_sale_order_weight.sale_weight_line_form +msgid " kg" +msgstr " kg" + +#. module: app_sale_order_weight +#: model:ir.model.fields,field_description:app_sale_order_weight.field_sale_order_line_weight_net +msgid "Net Weight(kg)" +msgstr "重量(kg)" + +#. module: app_sale_order_weight +#: model:ir.model,name:app_sale_order_weight.model_sale_order +msgid "Quotation" +msgstr "报价单" + +#. module: app_sale_order_weight +#: model:ir.model,name:app_sale_order_weight.model_sale_order_line +msgid "Sales Order Line" +msgstr "销售订单行" + +#. module: app_sale_order_weight +#: model:ir.model.fields,field_description:app_sale_order_weight.field_sale_order_total_weight_net +msgid "Total Weight (kg)" +msgstr "Total Weight (kg)" + +#. module: app_sale_order_weight +#: model:ir.ui.view,arch_db:app_sale_order_weight.sale_weight_line_form +msgid "Total Weight:" +msgstr "Total Weight:" + diff --git a/app_sale_order_weight/models/__init__.py b/app_sale_order_weight/models/__init__.py new file mode 100644 index 00000000..4ae612e7 --- /dev/null +++ b/app_sale_order_weight/models/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import sale_order +from . import sale_order_line + + diff --git a/app_sale_order_weight/models/sale_order.py b/app_sale_order_weight/models/sale_order.py new file mode 100644 index 00000000..9f4818bf --- /dev/null +++ b/app_sale_order_weight/models/sale_order.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + + +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 _compute_weight_total(self): + for sale in self: + weight_tot = 0 + for line in sale.order_line: + if line.product_id: + weight_tot += line.weight or 0.0 + sale.total_weight = weight_tot + diff --git a/app_sale_order_weight/models/sale_order_line.py b/app_sale_order_weight/models/sale_order_line.py new file mode 100644 index 00000000..d6cc3744 --- /dev/null +++ b/app_sale_order_weight/models/sale_order_line.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + + +from odoo import api, fields, models, _ + +# Record the net weight of the order line +class SaleOrderLine(models.Model): + _inherit = 'sale.order.line' + + weight = fields.Float(string='Weight(kg)', compute='_compute_weight', + inverse='_set_weight', store=True) + + def _compute_weight(self): + for line in self: + weight = 0 + if line.product_id and line.product_id.weight: + weight += (line.product_id.weight + * line.product_uom_qty / line.product_uom.factor) + line.weight = weight + + @api.one + def _set_weight(self): + pass diff --git a/app_sale_order_weight/static/description/banner.jpg b/app_sale_order_weight/static/description/banner.jpg new file mode 100644 index 00000000..c064ed42 Binary files /dev/null and b/app_sale_order_weight/static/description/banner.jpg differ diff --git a/app_sale_order_weight/static/description/icon.png b/app_sale_order_weight/static/description/icon.png new file mode 100644 index 00000000..4c57f611 Binary files /dev/null and b/app_sale_order_weight/static/description/icon.png differ diff --git a/app_sale_order_weight/static/description/index.html b/app_sale_order_weight/static/description/index.html new file mode 100644 index 00000000..2a6c69d5 --- /dev/null +++ b/app_sale_order_weight/static/description/index.html @@ -0,0 +1,43 @@ +
+
+
+

Sales Order Weight

+
+

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

+
+
+ +
+
+ +

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

+ +
+
+ +
+
+ +

+The calculation uses the following formula: +

+

+Sale_order_line_net_weight = (line_product_weight * line_product_uom_qty / line_product_uom_factor) +
+Total_weight = sum(Sale_order_line_net_weight) +

+
+

+ For any assistance please feel free to contact us: contact@broadtech-innovations.com +

+ + +
+
diff --git a/app_sale_order_weight/static/description/sale_weight.png b/app_sale_order_weight/static/description/sale_weight.png new file mode 100644 index 00000000..4760082b Binary files /dev/null and b/app_sale_order_weight/static/description/sale_weight.png differ diff --git a/app_sale_order_weight/static/description/sale_weight_product.png b/app_sale_order_weight/static/description/sale_weight_product.png new file mode 100644 index 00000000..af59a291 Binary files /dev/null and b/app_sale_order_weight/static/description/sale_weight_product.png differ diff --git a/app_sale_order_weight/views/sale_order_views.xml b/app_sale_order_weight/views/sale_order_views.xml new file mode 100644 index 00000000..90bfb434 --- /dev/null +++ b/app_sale_order_weight/views/sale_order_views.xml @@ -0,0 +1,52 @@ + + + + + + + sale.weight.view.tree + sale.order + + + + + + + + + + sale.quotation.weight.view.tree + sale.order + + + + + + + + + + + + sale.weight.view.line.form + sale.order + + + +
+
+ +
+ + + + + + +
+
+ +
+