summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/stock_move.py
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models/stock_move.py')
-rw-r--r--indoteknik_custom/models/stock_move.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/indoteknik_custom/models/stock_move.py b/indoteknik_custom/models/stock_move.py
index 6b631713..514acad0 100644
--- a/indoteknik_custom/models/stock_move.py
+++ b/indoteknik_custom/models/stock_move.py
@@ -13,6 +13,21 @@ class StockMove(models.Model):
)
qr_code_variant = fields.Binary("QR Code Variant", compute='_compute_qr_code_variant')
barcode = fields.Char(string='Barcode', related='product_id.barcode')
+ vendor_id = fields.Many2one('res.partner' ,string='Vendor')
+
+ @api.constrains('product_id')
+ def constrains_product_to_fill_vendor(self):
+ for rec in self:
+ if rec.product_id and rec.bom_line_id:
+ if rec.product_id.x_manufacture.override_vendor_id:
+ rec.vendor_id = rec.product_id.x_manufacture.override_vendor_id.id
+ else:
+ purchase_pricelist = self.env['purchase.pricelist'].search(
+ [('product_id', '=', rec.product_id.id),
+ ('is_winner', '=', True)],
+ limit=1)
+ if purchase_pricelist:
+ rec.vendor_id = purchase_pricelist.vendor_id.id
def _compute_qr_code_variant(self):
for rec in self: