[IMP] stock: displaying improvements

On some models, like picking, package and move, the weight was hardcoded
in 'kg', we instead use the value in the ir.config.parameter.

We also changed some field labels to give them more meaning.

Related Task ID: #1895297

closes odoo/odoo#27944
This commit is contained in:
Mitali Patel
2018-11-29 08:46:13 +00:00
committed by Pierre Masereel
parent 52f13c5f6d
commit d6abf593d7
5 changed files with 40 additions and 18 deletions
+20 -10
View File
@@ -20,8 +20,16 @@ class StockQuantPackage(models.Model):
weight += quant.quantity * quant.product_id.weight
self.weight = weight
weight = fields.Float(compute='_compute_weight', help="Weight computed based on the sum of the weights of the products.")
shipping_weight = fields.Float(string='Shipping Weight', help="Weight used to compute the price of the delivery (if applicable).")
def _get_default_weight_uom(self):
return self.env['product.template']._get_weight_uom_name_from_ir_config_parameter()
def _compute_weight_uom_name(self):
for package in self:
package.weight_uom_name = self.env['product.template']._get_weight_uom_name_from_ir_config_parameter()
weight = fields.Float(compute='_compute_weight', help="Total weight of all the products contained in the package.")
weight_uom_name = fields.Char(string='Weight unit of measure label', compute='_compute_weight_uom_name', readonly=True, default=_get_default_weight_uom)
shipping_weight = fields.Float(string='Shipping Weight', help="Total weight of the package.")
class StockMoveLine(models.Model):
@@ -74,28 +82,30 @@ class StockPicking(models.Model):
def _compute_shipping_weight(self):
self.shipping_weight = self.weight_bulk + sum([pack.shipping_weight for pack in self.package_ids])
def _get_default_weight_uom(self):
return self.env['product.template']._get_weight_uom_name_from_ir_config_parameter()
def _compute_weight_uom_name(self):
for package in self:
package.weight_uom_name = self.env['product.template']._get_weight_uom_name_from_ir_config_parameter()
carrier_price = fields.Float(string="Shipping Cost")
delivery_type = fields.Selection(related='carrier_id.delivery_type', readonly=True)
carrier_id = fields.Many2one("delivery.carrier", string="Carrier")
volume = fields.Float(copy=False)
weight = fields.Float(compute='_cal_weight', digits=dp.get_precision('Stock Weight'), store=True)
weight = fields.Float(compute='_cal_weight', digits=dp.get_precision('Stock Weight'), store=True, help="Total weight of the products in the picking.")
carrier_tracking_ref = fields.Char(string='Tracking Reference', copy=False)
carrier_tracking_url = fields.Char(string='Tracking URL', compute='_compute_carrier_tracking_url')
weight_uom_id = fields.Many2one('uom.uom', string='Unit of Measure', compute='_compute_weight_uom_id', help="Unit of measurement for Weight")
weight_uom_name = fields.Char(string='Weight unit of measure label', compute='_compute_weight_uom_name', readonly=True, default=_get_default_weight_uom)
package_ids = fields.Many2many('stock.quant.package', compute='_compute_packages', string='Packages')
weight_bulk = fields.Float('Bulk Weight', compute='_compute_bulk_weight')
shipping_weight = fields.Float("Weight for Shipping", compute='_compute_shipping_weight')
shipping_weight = fields.Float("Weight for Shipping", compute='_compute_shipping_weight', help="Total weight of the packages and products which are not in a package. That's the weight used to compute the cost of the shipping.")
@api.depends('carrier_id', 'carrier_tracking_ref')
def _compute_carrier_tracking_url(self):
for picking in self:
picking.carrier_tracking_url = picking.carrier_id.get_tracking_link(picking) if picking.carrier_id and picking.carrier_tracking_ref else False
def _compute_weight_uom_id(self):
weight_uom_id = self.env['product.template']._get_weight_uom_id_from_ir_config_parameter()
for picking in self:
picking.weight_uom_id = weight_uom_id
@api.depends('move_lines')
def _cal_weight(self):
for picking in self:
+17 -5
View File
@@ -204,7 +204,7 @@
<field name="arch" type="xml">
<data>
<xpath expr="//group[@name='other_infos']" position="before">
<group name='carrier_data' string="Delivery Information">
<group name='carrier_data' string="Shipping Information">
<field name="carrier_id" attrs="{'readonly': [('state', 'in', ('done', 'cancel'))]}" options="{'no_create': True, 'no_open': True}"/>
<field name="delivery_type" attrs="{'invisible':True}"/>
<label for="carrier_tracking_ref"/>
@@ -215,9 +215,13 @@
<label for="weight" string="Weight"/>
<div>
<field name="weight" class="oe_inline"/>
<field name="weight_uom_id" nolabel="1" class="oe_inline" style="margin-left:5px"/>
<field name="weight_uom_name" nolabel="1" class="oe_inline" style="margin-left:5px"/>
</div>
<label for="shipping_weight" string="Weight for shipping"/>
<div>
<field name="shipping_weight" class="oe_inline"/>
<field name="weight_uom_name" nolabel="1" class="oe_inline" style="margin-left:5px"/>
</div>
<field name="shipping_weight"/>
</group>
</xpath>
<div name="button_box" position="inside">
@@ -255,8 +259,16 @@
<field name="arch" type="xml">
<field name="company_id" position="before">
<field name="packaging_id" domain="[('product_id', '=', False)]"/>
<field name="weight"/>
<field name="shipping_weight"/>
<label for="weight" string="Weight"/>
<div>
<field name="weight" class="oe_inline"/>
<field name="weight_uom_name" nolabel="1" class="oe_inline" style="margin-left:5px"/>
</div>
<label for="shipping_weight"/>
<div class="o_row" name="Shipping Weight">
<field name="shipping_weight"/>
<span><field name="weight_uom_name"/></span>
</div>
</field>
</field>
</record>
@@ -11,7 +11,7 @@
</td>
<td t-if="o.shipping_weight">
<span t-field="o.shipping_weight"/>
<span t-field="o.weight_uom_id"/>
<span t-field="o.weight_uom_name"/>
</td>
<td t-if="o.carrier_tracking_ref">
<span t-field="o.carrier_tracking_ref"/>
+1 -1
View File
@@ -10,7 +10,7 @@
</td>
<td t-if="o.weight">
<span t-field="o.weight"/>
<span t-field="o.weight_uom_id"/>
<span t-field="o.weight_uom_name"/>
</td>
</xpath>
</template>
+1 -1
View File
@@ -627,7 +627,7 @@ class ProductPackaging(models.Model):
name = fields.Char('Package Type', required=True)
sequence = fields.Integer('Sequence', default=1, help="The first in the sequence is the default one.")
product_id = fields.Many2one('product.product', string='Product')
qty = fields.Float('Contained Quantity', help="The total number of products you can have per pallet or box.")
qty = fields.Float('Contained Quantity', help="Quantity of products contained in the packaging.")
barcode = fields.Char('Barcode', copy=False, help="Barcode used for packaging identification.")
product_uom_id = fields.Many2one('uom.uom', related='product_id.uom_id', readonly=True)