diff options
| author | HafidBuroiroh <hafidburoiroh09@gmail.com> | 2026-03-13 17:27:49 +0700 |
|---|---|---|
| committer | HafidBuroiroh <hafidburoiroh09@gmail.com> | 2026-03-13 17:27:49 +0700 |
| commit | f4d0b63e800b068011aa8c391ba601b3be878afc (patch) | |
| tree | 47f0a65f21d9528fce7162be004c741d026fd91f /indoteknik_custom | |
| parent | 6bd1655cde52bbd430552b9a9484a69a26ab58e2 (diff) | |
<hafid> fix vendor purchase pricelist
Diffstat (limited to 'indoteknik_custom')
| -rw-r--r-- | indoteknik_custom/models/sourcing_job_order.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/indoteknik_custom/models/sourcing_job_order.py b/indoteknik_custom/models/sourcing_job_order.py index e6a177f8..a107b5ae 100644 --- a/indoteknik_custom/models/sourcing_job_order.py +++ b/indoteknik_custom/models/sourcing_job_order.py @@ -345,6 +345,8 @@ class SourcingJobOrderLine(models.Model): last_updated_price = fields.Datetime(string='Last Update Price', readonly=True) tax_id = fields.Many2one('account.tax', string='Tax', domain=[('active', '=', True), ('type_tax_use', '=', 'purchase')]) vendor_id = fields.Many2one('res.partner', string="Vendor") + uom_id = fields.Many2one('uom.uom', string="Unit of Measure") + web_tax_id = fields.Many2one('account.tax', string="Website Tax") product_category = fields.Many2one('product.category', string="Product Category") product_class = fields.Many2many('product.public.category', string="Categories") exported_to_so = fields.Boolean(string="Exported to SO", default=False) @@ -673,6 +675,12 @@ class SourcingJobOrderLine(models.Model): if not line.product_name_md: missing_fields.append("Product Name") + if not line.web_tax_id: + missing_fields.append("Website Tax") + + if not line.uom_id: + missing_fields.append("Unit of Measure") + if not line.brand_id: missing_fields.append("Manufactures") @@ -774,8 +782,8 @@ class SourcingJobOrderLine(models.Model): for rec in self: job = rec.order_id - if job.create_uid != self.env.user: - raise UserError("❌ Hanya pembuat Sourcing Job yang bisa approve.") + if job.show_salesperson or job.show_salesperson.id != self.env.uid: + raise UserError("❌ Hanya Salesperson Sale Order yang bisa approve.") rec.write({'state': 'approve'}) @@ -805,6 +813,9 @@ class SourcingJobOrderLine(models.Model): 'name': rec.product_name_md, 'default_code': rec.code or False, 'description': rec.descriptions_md or '', + 'web_tax_id': rec.web_tax_id.id or False, + 'uom_id': rec.uom_id.id or False, + 'uom_po_id': rec.uom_id.id or False, 'type': type_map.get(rec.product_type, 'product'), 'categ_id': rec.product_category.id if rec.product_category else False, 'x_manufacture': rec.brand_id.id if rec.brand_id else False, @@ -820,6 +831,9 @@ class SourcingJobOrderLine(models.Model): product.default_code = sku_auto rec.code = sku_auto + if product.categ_id or product.categ_id.id == 34: + product.unpublished = True + rec.product_id = product.id self.env.user.notify_success( @@ -847,6 +861,9 @@ class SourcingJobOrderLine(models.Model): if not purchase_price: PurchasePricelist.create(pricelist_vals) + if product.categ_id and product.categ_id.id != 34: + PurchasePricelist.create(pricelist_vals) + elif purchase_price.product_price != (rec.price or 0): purchase_price.write(pricelist_vals) |
