weight for stock.move
parent
61e77cf92b
commit
1ddfd06773
|
|
@ -60,3 +60,42 @@ class StockPicking(models.Model):
|
|||
|
||||
res = lang_obj.format('%.' + str(2) + 'f', value, grouping=True, monetary=True)
|
||||
return res
|
||||
|
||||
class StockMove(models.Model):
|
||||
_inherit = "stock.move"
|
||||
|
||||
manu_lots_visible = fields.Boolean(compute='_compute_manu_lots_visible')
|
||||
|
||||
@api.multi
|
||||
def _prepare_move_line_vals(self, quantity=None, reserved_quant=None):
|
||||
self.ensure_one()
|
||||
vals = super(StockMove, self)._prepare_move_line_vals(quantity=quantity, reserved_quant=reserved_quant)
|
||||
if self.sale_line_id.lot_id and not self.sale_line_id.product_id.can_be_sold_unconfigured:
|
||||
move_lot = self.sale_line_id.lot_id.id
|
||||
vals.update({'lot_id': move_lot, })
|
||||
return vals
|
||||
|
||||
def _compute_manu_lots_visible(self):
|
||||
for move_line in self:
|
||||
if not move_line.product_id.can_be_sold_unconfigured:
|
||||
move_line.manu_lots_visible = True
|
||||
|
||||
@api.multi
|
||||
def action_show_lot(self):
|
||||
self.ensure_one()
|
||||
action = self.env.ref('stock.action_production_lot_form').read()[0]
|
||||
action['res_id'] = self.move_line_ids.lot_id.id
|
||||
action['view_mode'] = 'form'
|
||||
action['views'] = [(False, 'form')]
|
||||
|
||||
return action
|
||||
|
||||
@api.depends('product_id', 'product_uom_qty', 'product_uom')
|
||||
def _cal_move_weight(self):
|
||||
for move in self:
|
||||
if move.sale_line_id.lot_id and not move.product_id.can_be_sold_unconfigured:
|
||||
move.weight += (move.product_qty * move.sale_line_id.lot_id.weight)
|
||||
else:
|
||||
move.weight += (move.product_qty * move.product_id.weight)
|
||||
|
||||
# print(move.weight)
|
||||
|
|
@ -22,4 +22,17 @@
|
|||
<field name="priority">0</field>
|
||||
</record>
|
||||
|
||||
<record id="view_delivery_manu_lot" model="ir.ui.view">
|
||||
<field name="name">view_delivery_manu_lot</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='move_lines']/tree//field[@name='product_id']" position="after">
|
||||
<field name="manu_lots_visible" invisible="1"/>
|
||||
<button name="action_show_lot" string="Lot for manufactoring parts" type="object" icon="fa-list" attrs="{'invisible': [('manu_lots_visible', '=', False)]}" options="{"warn": true}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</odoo>
|
||||
|
|
|
|||
|
|
@ -176,10 +176,14 @@
|
|||
<th>
|
||||
<strong>Product</strong>
|
||||
</th>
|
||||
<th name="lot_serial" t-if="has_serial_number">
|
||||
<!-- <th name="lot_serial" t-if="has_serial_number"> -->
|
||||
<th class="text-center" name="lot_serial" t-if="has_serial_number and any([move_line.product_id.can_be_sold_unconfigured for move_line in o.move_line_ids])">
|
||||
Lot/Serial Number
|
||||
</th>
|
||||
<th class="text-center">
|
||||
<strong>Weight</strong>
|
||||
</th>
|
||||
<th class="text-right">
|
||||
<strong>Ordered Quantity</strong>
|
||||
</th>
|
||||
<th t-if="any([move_line.state == 'done' for move_line in o.move_line_ids])"
|
||||
|
|
@ -209,14 +213,11 @@
|
|||
</t>
|
||||
</td>
|
||||
<t t-if="has_serial_number">
|
||||
<td>
|
||||
<td class="text-center">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
<span t-field="move_line.lot_id"/>
|
||||
<t t-if="not move_line.lot_id">
|
||||
<span t-field="move_line.lot_name"/>
|
||||
</t>
|
||||
<span t-field="move_line.lot_id" t-if="move_line.product_id.can_be_sold_unconfigured"/>
|
||||
</td>
|
||||
<td name="lot_qty">
|
||||
<t t-if="move_line.product_qty">
|
||||
|
|
@ -228,6 +229,16 @@
|
|||
</td>
|
||||
</t>
|
||||
<td class="text-center">
|
||||
<t t-if="not move_line.lot_id or move_line.product_id.can_be_sold_unconfigured">
|
||||
<span t-esc="move_line.ordered_qty*move_line.product_id.weight"/>
|
||||
<!-- <span t-field="move_line.product_id.weight"/> -->
|
||||
</t>
|
||||
<t t-if="move_line.lot_id and not move_line.product_id.can_be_sold_unconfigured">
|
||||
<!-- <t t-set="weight" t-value="move_line.ordered_qty*move_line.lot_id.weight"/> -->
|
||||
<span t-field="move_line.lot_id.weight"/>
|
||||
</t>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<span t-field="move_line.package_id"/>
|
||||
<span t-if="move_line.package_id">:</span>
|
||||
<!--
|
||||
|
|
|
|||
Loading…
Reference in New Issue