diff options
| author | Miqdad <ahmadmiqdad27@gmail.com> | 2025-10-14 21:20:57 +0700 |
|---|---|---|
| committer | Miqdad <ahmadmiqdad27@gmail.com> | 2025-10-14 21:20:57 +0700 |
| commit | 5a181ec0100dcb7ad5742f757195599deffa2b29 (patch) | |
| tree | f29b015881da2c8385f166c0bb8f7060ccb55a5e | |
| parent | 60dfef625548cf7e8cdaa8fdfd76238f208790e7 (diff) | |
<miqdad> make move line to get uom from so line
| -rw-r--r-- | indoteknik_custom/models/stock_move.py | 17 |
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 |
