From e64f920d2e84b2245d1af98c73a2520d68938192 Mon Sep 17 00:00:00 2001 From: ivan deng Date: Fri, 14 Dec 2018 13:06:50 +0800 Subject: [PATCH] opt sale weight. --- app_product_weight_sale/i18n/zh_CN.po | 42 ++++++++++++++----- .../models/sale_order_line.py | 12 +++--- .../views/sale_order_views.xml | 2 + 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/app_product_weight_sale/i18n/zh_CN.po b/app_product_weight_sale/i18n/zh_CN.po index 1e294ea5..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_weight_total +#: 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_line.py b/app_product_weight_sale/models/sale_order_line.py index 79851178..0e90886d 100644 --- a/app_product_weight_sale/models/sale_order_line.py +++ b/app_product_weight_sale/models/sale_order_line.py @@ -9,18 +9,20 @@ from odoo import api, fields, models, _ class SaleOrderLine(models.Model): _inherit = 'sale.order.line' - weight = fields.Float(string='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', related='product_id.weight', store=True, readonly=True) weight_subtotal = fields.Float(string='Weight Subtotal', compute='_compute_weight_subtotal', inverse='_set_weight_subtotal', store=True) @api.multi - @api.depends('product_id', 'product_uom_qty') + @api.depends('product_id', 'product_uom', 'product_uom_qty') def _compute_weight_subtotal(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) - line.weight = weight + weight_subtotal += (line.product_id.weight * line.product_uom_qty / line.product_uom.factor) + line.weight_subtotal = weight_subtotal @api.one def _set_weight_subtotal(self): diff --git a/app_product_weight_sale/views/sale_order_views.xml b/app_product_weight_sale/views/sale_order_views.xml index 091de436..12596c69 100644 --- a/app_product_weight_sale/views/sale_order_views.xml +++ b/app_product_weight_sale/views/sale_order_views.xml @@ -41,9 +41,11 @@ + +