summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indoteknik_custom/models/stock_move.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/indoteknik_custom/models/stock_move.py b/indoteknik_custom/models/stock_move.py
index b7db8775..1da2befe 100644
--- a/indoteknik_custom/models/stock_move.py
+++ b/indoteknik_custom/models/stock_move.py
@@ -21,6 +21,14 @@ class StockMove(models.Model):
product_image = fields.Binary(related="product_id.image_128", string="Product Image", readonly=True)
partial = fields.Boolean('Partial?', default=False)
+ # Ambil product uom dari SO line
+ @api.model
+ def create(self, vals):
+ if vals.get('sale_line_id'):
+ sale_line = self.env['sale.order.line'].browse(vals['sale_line_id'])
+ vals['product_uom'] = sale_line.product_uom.id
+ return super().create(vals)
+
# @api.model_create_multi
# def create(self, vals_list):
# moves = super(StockMove, self).create(vals_list)
@@ -178,3 +186,12 @@ class StockMoveLine(models.Model):
line_no = fields.Integer('No', default=0)
note = fields.Char('Note')
manufacture = fields.Many2one('x_manufactures', string="Brands", related="product_id.x_manufacture", store=True)
+
+ # Ambil uom dari stock move
+ @api.model
+ def create(self, vals):
+ if 'move_id' in vals and 'product_uom_id' not in vals:
+ move = self.env['stock.move'].browse(vals['move_id'])
+ if move.product_uom:
+ vals['product_uom_id'] = move.product_uom.id
+ return super().create(vals) \ No newline at end of file