diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2025-12-01 10:03:29 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2025-12-01 10:03:29 +0700 |
| commit | 15377b23022440d88c40c656a513b3397ba43e9a (patch) | |
| tree | b6ae76c8eb15e54a5c3a1eb1ca4106044f9dc11e /fixco_custom/models/purchase_pricelist_wizard.py | |
| parent | 9c3a7bba06bba9db22d84286f96739ef37e49ace (diff) | |
push revisi hari sabtu tanggal 29/11/25
Diffstat (limited to 'fixco_custom/models/purchase_pricelist_wizard.py')
| -rw-r--r-- | fixco_custom/models/purchase_pricelist_wizard.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/fixco_custom/models/purchase_pricelist_wizard.py b/fixco_custom/models/purchase_pricelist_wizard.py new file mode 100644 index 0000000..70ac54f --- /dev/null +++ b/fixco_custom/models/purchase_pricelist_wizard.py @@ -0,0 +1,29 @@ +from odoo import models, fields + +class PurchasePricelistWizard(models.TransientModel): + _name = 'purchase.pricelist.wizard' + _description = 'Wizard Create Purchase Pricelist' + + product_id = fields.Many2one('product.product', string="Product", required=True) + vendor_id = fields.Many2one('res.partner', string="Vendor", required=True, domain="[('supplier_rank','>',0)]") + price = fields.Float(string="Price", required=True) + + def action_create_pricelist(self): + self.ensure_one() + + existing = self.env['purchase.pricelist'].search([ + ('product_id', '=', self.product_id.id) + ], limit=1) + + if existing: + existing.vendor_id = self.vendor_id.id + existing.price = self.price + return {'type': 'ir.actions.act_window_close'} + + self.env['purchase.pricelist'].create({ + 'product_id': self.product_id.id, + 'vendor_id': self.vendor_id.id, + 'price': self.price, + }) + + return {'type': 'ir.actions.act_window_close'} |
