add weight

This commit is contained in:
ivan deng
2019-01-29 01:51:26 +08:00
parent 633e962aec
commit d853558a4e
14 changed files with 132 additions and 43 deletions

View File

@@ -2,12 +2,13 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details. # Part of Odoo. See LICENSE file for full copyright and licensing details.
{ {
'name': 'App Product Weight in Sales Order', 'name': 'Weight in Sales Order',
'version': '11.19.01.03', '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', '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, 'sequence': 10,
'license': 'LGPL-3', 'license': 'LGPL-3',
'description': """ 'description': """
All in one Weight solution for sale, purchase, purchase agreement, stock. Please check follow <strong>Pay</strong> app.
Add product sku weight in Sale Order. Unit of measure auto weight, kg kg(s) lb lb(s) support. weight sale order. 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。 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) Support kg(s) or lb(s)
@@ -15,7 +16,7 @@
'category': 'Sales', 'category': 'Sales',
'author': 'Sunpop.cn', 'author': 'Sunpop.cn',
'website': 'http://www.sunpop.cn', 'website': 'http://www.sunpop.cn',
'images': ['static/description/banner.jpg'], 'images': ['static/description/banner.png'],
'currency': 'EUR', 'currency': 'EUR',
'price': 38, 'price': 38,
'depends': ['sale_management'], 'depends': ['sale_management'],

View File

@@ -4,10 +4,10 @@
# #
msgid "" msgid ""
msgstr "" 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" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-02 15:10+0000\n" "POT-Creation-Date: 2019-01-28 10:38+0000\n"
"PO-Revision-Date: 2019-01-02 15:10+0000\n" "PO-Revision-Date: 2019-01-28 10:38+0000\n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@@ -26,7 +26,9 @@ msgid "Sales Order Line"
msgstr "销售订单行" msgstr "销售订单行"
#. module: app_product_weight_sale #. 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" msgid "Total Weight"
msgstr "总重量" msgstr "总重量"
@@ -35,23 +37,18 @@ msgstr "总重量"
msgid "Total Weight:" 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"
msgstr "单位重量"
#. module: app_product_weight_sale #. module: app_product_weight_sale
#: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order__weight_uom_name #: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order__weight_uom_name
msgid "Weight Measure" msgid "Weight Measure"
msgstr "重量单位" msgstr "重量单位"
#. module: app_product_weight_sale #. 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" msgid "Weight Subtotal"
msgstr "重量小计" msgstr "重量小计"
#. module: app_product_weight_sale #. module: app_product_weight_sale
#: model:ir.model.fields,help:app_product_weight_sale.field_sale_order_line__weight #: model:ir.model.fields,field_description:app_product_weight_sale.field_sale_order_line__weight_unit
msgid "Weight of the product, packaging not included. The unit of measure can be changed in the general settings" msgid "Weight Unit"
msgstr "产品重量、包装不包括在内。可以在一般设置中改变测量单位。" msgstr "单位重量"

View File

@@ -15,15 +15,17 @@ class SaleOrder(models.Model):
else: else:
return self.env.ref('uom.product_uom_kgm').name 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) 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: for rec in self:
weight_tot = 0 weight_tot = 0
for line in rec.order_line: for line in rec.order_line:
if line.product_id: if line.product_id:
weight_tot += line.weight_subtotal or 0.0 weight_tot += line.weight or 0.0
rec.weight_total = weight_tot rec.weight = weight_tot

View File

@@ -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_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) # 调整,根据 delivery 模块,将 weight 作为 该行合计weight_unit 作为该单位的
weight_subtotal = fields.Float(string='Weight Subtotal', compute='_compute_weight', store=True) 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.multi
@api.depends('product_id', 'product_uom', 'product_uom_qty') @api.depends('product_id', 'product_uom', 'product_uom_qty')
def _compute_weight(self): def _compute_weight(self):
for line in self: for line in self.filtered(lambda rec: rec.product_id.weight > 0.00):
weight = 0 weight = 0
weight_subtotal = 0 try:
if line.product_id and line.product_id.weight: weight_unit = line.product_id.weight / line.product_uom.factor
weight = line.product_id.weight / line.product_uom.factor except:
weight_subtotal += (weight * line.product_uom_qty) weight_unit = line.product_id.weight
weight += (weight_unit * line.product_uom_qty)
line.weight_unit = weight_unit
line.weight = weight line.weight = weight
line.weight_subtotal = weight_subtotal
@api.one @api.one
def _set_weight_subtotal(self): def _set_weight_subtotal(self):

Binary file not shown.

Before

Width:  |  Height:  |  Size: 287 KiB

After

Width:  |  Height:  |  Size: 95 KiB

View File

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

View File

@@ -2,10 +2,51 @@
<div class="oe_row oe_spaced"> <div class="oe_row oe_spaced">
<div class="oe_span12"> <div class="oe_span12">
<h2 class="oe_slogan">Sales Order Weight</h2> <h2 class="oe_slogan">Sales Order Weight</h2>
<img class="oe_screenshot oe_picture" src="demo_all.png">
</div> </div>
<div class="alert alert-info" style="padding:8px;font-weight: 300; font-size: 20px;"> <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> <i class="fa fa-hand-o-right"></i><b> Key features: </b>
<ul class="list-unstyled"> <ul class="list-unstyled">
<li>
<i class="fa fa-check-square-o text-primary"></i>
All in one Weight solution for sale, purchase, purchase agreement, stock. Please check follow <strong>Pay</strong> app.
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
Product auto weight is ready.
<a href="http://www.odoo.com/apps/modules/12.0/app_product_weight_auto/" target="_blank">
<i class="fa fa-download text-warning"></i>Click to download.
</a>
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
Sale order Product weight is ready.
<a href="http://www.odoo.com/apps/modules/12.0/app_product_weight_sale/" target="_blank">
<i class="fa fa-download text-warning"></i>Click to download.
</a>
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
Purchase order Product weight is ready.
<a href="http://www.odoo.com/apps/modules/12.0/app_product_weight_purchase/" target="_blank">
<i class="fa fa-download text-warning"></i>Click to download.
</a>
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
Purchase agreement Product weight is ready.
<a href="http://www.odoo.com/apps/modules/12.0/app_product_weight_purchase_requisition/" target="_blank">
<i class="fa fa-download text-warning"></i>Click to download.
</a>
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
Stock picking operation Product weight is ready.
<a href="http://www.odoo.com/apps/modules/12.0/app_product_weight_stock/" target="_blank">
<i class="fa fa-download text-warning"></i>Click to download.
</a>
</li>
<li> <li>
<i class="fa fa-check-square-o text-primary"></i> <i class="fa fa-check-square-o text-primary"></i>
Add product sku weight in Sale Order line. Add product sku weight in Sale Order line.
@@ -20,6 +61,9 @@
</li> </li>
</ul> </ul>
</div> </div>
<div class="oe_demo oe_screenshot">
<img class="oe_screenshot" src="demo.jpg">
</div>
<p class='oe_mt32'> <p class='oe_mt32'>
</p> </p>
<div class="oe_demo oe_screenshot"> <div class="oe_demo oe_screenshot">
@@ -42,16 +86,59 @@
</h3> </h3>
<img class="oe_screenshot" src="demo1.jpg"> <img class="oe_screenshot" src="demo1.jpg">
</div> </div>
<p class='oe_span12 oe_mt32'> <p class='oe_span12 oe_mt32'>
The calculation uses the following formula: The calculation uses the following formula:
</p> </p>
<p class='oe_mt32'> <p class='oe_mt32'>
order_line_net_weight = (line_product_weight / line_product_uom_factor) order_line_net_weight = (line_product_weight / line_product_uom_factor)
<br/> <br/>
weight_total = sum(order_line_net_weight) weight_total = sum(order_line_net_weight)
</p> </p>
</div>
</section>
<section class="oe_container">
<h1>Weight app relate.</h1>
<div class="oe_row oe_spaced">
<h4 class="oe_slogan">Use in product auto weight</h4>
<div class="oe_demo oe_screenshot">
<img src="demo_product.jpg">
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h4 class="oe_slogan">Use in sale order</h4>
<div class="oe_demo oe_screenshot">
<img src="demo_sale.jpg">
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h4 class="oe_slogan">Use in Purcahse Order</h4>
<div class="oe_demo oe_screenshot">
<img src="demo_purchase.jpg">
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h4 class="oe_slogan">Use in Purcahse Agreement</h4>
<div class="oe_demo oe_screenshot">
<img src="demo_purchase_requisition.jpg">
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h4 class="oe_slogan">Use in Stock Picking </h4>
<div class="oe_demo oe_screenshot">
<img src="demo_stock.jpg">
</div>
</div> </div>
</section> </section>

View File

@@ -9,7 +9,7 @@
<field name="inherit_id" ref="sale.view_order_tree"/> <field name="inherit_id" ref="sale.view_order_tree"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='amount_total']" position="before"> <xpath expr="//field[@name='amount_total']" position="before">
<field name="weight_total" sum="Total Weight"/> <field name="weight" sum="Total Weight"/>
</xpath> </xpath>
</field> </field>
</record> </record>
@@ -20,7 +20,7 @@
<field name="inherit_id" ref="sale.view_quotation_tree"/> <field name="inherit_id" ref="sale.view_quotation_tree"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='amount_total']" position="before"> <xpath expr="//field[@name='amount_total']" position="before">
<field name="weight_total" sum="Total Weight"/> <field name="weight" sum="Total Weight"/>
</xpath> </xpath>
</field> </field>
</record> </record>
@@ -34,18 +34,18 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='note']" position="before"> <xpath expr="//field[@name='note']" position="before">
<div> <div>
<label for="weight_total" name="weight_total" string="Total Weight: " class="oe_inline"/> <label for="weight" name="weight" string="Total Weight: " class="oe_inline"/>
<field name="weight_total" class="oe_inline"/><span> <field name="weight_uom_name" class="oe_inline"/></span> <field name="weight" class="oe_inline"/><span> <field name="weight_uom_name" class="oe_inline"/></span>
</div> </div>
<newline/> <newline/>
</xpath> </xpath>
<xpath expr="//field[@name='order_line']/tree//field[@name='product_uom']" position="after"> <xpath expr="//field[@name='order_line']/tree//field[@name='product_uom']" position="after">
<field name="weight_unit" invisible="1"/>
<field name="weight"/> <field name="weight"/>
<field name="weight_subtotal"/>
</xpath> </xpath>
<xpath expr="//field[@name='order_line']/form//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_unit" invisible="1"/>
<field name="weight_subtotal"/> <field name="weight"/>
</xpath> </xpath>
</field> </field>
</record> </record>