diff options
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'} |
