diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2025-10-15 11:35:07 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2025-10-15 11:35:07 +0000 |
| commit | 9267206952be1588640115e20fe1d41eaa138979 (patch) | |
| tree | b3d5d321a9a6d71cd5783f7c68a2e56ccf38d7df | |
| parent | ee6d5d4433a397ca5cdf3474f29bcbd0b2553736 (diff) | |
| parent | 5a181ec0100dcb7ad5742f757195599deffa2b29 (diff) | |
Merged in uom_move_line (pull request #449)
<miqdad> move line 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 |
