diff --git a/app_product_weight_sale/__manifest__.py b/app_product_weight_sale/__manifest__.py index 14567ec9..eec0e0a8 100644 --- a/app_product_weight_sale/__manifest__.py +++ b/app_product_weight_sale/__manifest__.py @@ -2,12 +2,13 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. { - 'name': 'App Product Weight in Sales Order', - 'version': '11.19.01.03', + 'name': 'Weight in Sales Order', + 'version': '11.19.01.29', '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', 'description': """ + All in one Weight solution for sale, purchase, purchase agreement, stock. Please check follow Pay app. Add product sku weight in Sale Order. Unit of measure auto weight, kg kg(s) lb lb(s) support. weight 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。 Support kg(s) or lb(s) @@ -15,7 +16,7 @@ 'category': 'Sales', 'author': 'Sunpop.cn', 'website': 'http://www.sunpop.cn', - 'images': ['static/description/banner.jpg'], + 'images': ['static/description/banner.png'], 'currency': 'EUR', 'price': 38, 'depends': ['sale_management'], diff --git a/app_product_weight_sale/i18n/zh_CN.po b/app_product_weight_sale/i18n/zh_CN.po index e8bc69d8..afa423f5 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 12.0+e-20181221\n" +"Project-Id-Version: Odoo Server 12.0+e-20190124\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-01-02 15:10+0000\n" -"PO-Revision-Date: 2019-01-02 15:10+0000\n" +"POT-Creation-Date: 2019-01-28 10:38+0000\n" +"PO-Revision-Date: 2019-01-28 10:38+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -26,7 +26,9 @@ 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 +#: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order__weight +#: model_terms:ir.ui.view,arch_db:app_product_weight_sale.sale_quotation_weight_tree +#: model_terms:ir.ui.view,arch_db:app_product_weight_sale.sale_weight_tree msgid "Total Weight" msgstr "总重量" @@ -35,23 +37,18 @@ msgstr "总重量" msgid "Total Weight:" msgstr "总重量" -#. module: app_product_weight_sale -#: 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__weight_uom_name msgid "Weight Measure" -msgstr "重量单位名" +msgstr "重量单位" #. module: app_product_weight_sale -#: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order_line__weight_subtotal +#: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order_line__weight 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 "产品重量、包装不包括在内。可以在一般设置中改变测量单位。" +#: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order_line__weight_unit +msgid "Weight Unit" +msgstr "单位重量" diff --git a/app_product_weight_sale/models/sale_order.py b/app_product_weight_sale/models/sale_order.py index bf347fd7..bb56e9e2 100644 --- a/app_product_weight_sale/models/sale_order.py +++ b/app_product_weight_sale/models/sale_order.py @@ -15,15 +15,17 @@ class SaleOrder(models.Model): else: return self.env.ref('uom.product_uom_kgm').name - weight_total = fields.Float(string='Total Weight', compute='_compute_weight_total') + weight = fields.Float(string='Total Weight', compute='_compute_weight') # 重量显示的单位 weight_uom_name = fields.Char(string='Weight Measure', default=_get_default_weight_uom_name, readonly=True) - def _compute_weight_total(self): + @api.multi + @api.depends('order_line.weight') + def _compute_weight(self): for rec in self: weight_tot = 0 for line in rec.order_line: if line.product_id: - weight_tot += line.weight_subtotal or 0.0 - rec.weight_total = weight_tot + weight_tot += line.weight or 0.0 + rec.weight = 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 23fd1851..026d5cf6 100644 --- a/app_product_weight_sale/models/sale_order_line.py +++ b/app_product_weight_sale/models/sale_order_line.py @@ -11,20 +11,22 @@ class SaleOrderLine(models.Model): # 显示的单位,影响性能暂时不使用 # 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', store=True) - weight_subtotal = fields.Float(string='Weight Subtotal', compute='_compute_weight', store=True) + # 调整,根据 delivery 模块,将 weight 作为 该行合计,weight_unit 作为该单位的 + weight_unit = fields.Float(string='Weight Unit', compute='_compute_weight', store=True) + weight = fields.Float(string='Weight Subtotal', compute='_compute_weight', store=True) @api.multi @api.depends('product_id', 'product_uom', 'product_uom_qty') def _compute_weight(self): - for line in self: + for line in self.filtered(lambda rec: rec.product_id.weight > 0.00): weight = 0 - weight_subtotal = 0 - if line.product_id and line.product_id.weight: - weight = line.product_id.weight / line.product_uom.factor - weight_subtotal += (weight * line.product_uom_qty) + try: + weight_unit = line.product_id.weight / line.product_uom.factor + except: + weight_unit = line.product_id.weight + weight += (weight_unit * line.product_uom_qty) + line.weight_unit = weight_unit line.weight = weight - line.weight_subtotal = weight_subtotal @api.one def _set_weight_subtotal(self): diff --git a/app_product_weight_sale/static/description/banner.png b/app_product_weight_sale/static/description/banner.png index 205ef176..e6bb426b 100644 Binary files a/app_product_weight_sale/static/description/banner.png and b/app_product_weight_sale/static/description/banner.png differ diff --git a/app_product_weight_sale/static/description/banner.jpg b/app_product_weight_sale/static/description/demo.jpg similarity index 100% rename from app_product_weight_sale/static/description/banner.jpg rename to app_product_weight_sale/static/description/demo.jpg diff --git a/app_product_weight_sale/static/description/demo_all.png b/app_product_weight_sale/static/description/demo_all.png new file mode 100644 index 00000000..50a3dc11 Binary files /dev/null and b/app_product_weight_sale/static/description/demo_all.png differ diff --git a/app_product_weight_sale/static/description/demo_product.jpg b/app_product_weight_sale/static/description/demo_product.jpg new file mode 100644 index 00000000..e2da71db Binary files /dev/null and b/app_product_weight_sale/static/description/demo_product.jpg differ diff --git a/app_product_weight_sale/static/description/demo_purchase.jpg b/app_product_weight_sale/static/description/demo_purchase.jpg new file mode 100644 index 00000000..c24952fc Binary files /dev/null and b/app_product_weight_sale/static/description/demo_purchase.jpg differ diff --git a/app_product_weight_sale/static/description/demo_purchase_requisition.jpg b/app_product_weight_sale/static/description/demo_purchase_requisition.jpg new file mode 100644 index 00000000..7556bcdb Binary files /dev/null and b/app_product_weight_sale/static/description/demo_purchase_requisition.jpg differ diff --git a/app_product_weight_sale/static/description/demo_sale.jpg b/app_product_weight_sale/static/description/demo_sale.jpg new file mode 100644 index 00000000..e3de4f89 Binary files /dev/null and b/app_product_weight_sale/static/description/demo_sale.jpg differ diff --git a/app_product_weight_sale/static/description/demo_stock.jpg b/app_product_weight_sale/static/description/demo_stock.jpg new file mode 100644 index 00000000..37b2b661 Binary files /dev/null and b/app_product_weight_sale/static/description/demo_stock.jpg differ diff --git a/app_product_weight_sale/static/description/index.html b/app_product_weight_sale/static/description/index.html index 2eed82af..3e1f14c4 100644 --- a/app_product_weight_sale/static/description/index.html +++ b/app_product_weight_sale/static/description/index.html @@ -2,10 +2,51 @@
+
The calculation uses the following formula:
-
-order_line_net_weight = (line_product_weight / line_product_uom_factor)
-
-weight_total = sum(order_line_net_weight)
-
+ order_line_net_weight = (line_product_weight / line_product_uom_factor)
+
+ weight_total = sum(order_line_net_weight)
+
+
+
+
+
+