ICTSTUDIO / odoo-extra-addons

Extra Addons
20 stars 52 forks source link

product_pricelist_prices not saving changes: KeyError: 'product.price.type' #32

Open crgb001 opened 5 years ago

crgb001 commented 5 years ago

Error while trying to save changes made to a pricelist item:

KeyError: 'product.price.type'

CostaNelson commented 5 years ago

Error still not corrected: KeyError: 'product.price.type'

MartianX commented 5 years ago

i had the same issues and i managed to fix it by changing the price_set function like this : def price_set(self, product_template, new_price): """ Set the price of the product in current pricelist if different from price through pricerules :param product_template: product_template object :param new_price: new price :return: """ if new_price:

        items = self.env['product.pricelist.item'].search(
                [
                    ('product_tmpl_id', '=', product_template.id),
                    ('pricelist_id', '=', self.id)
                ]
        )            
        product_price_type_ids = self.env['product.pricelist.item'].search(
                [
                    ('base', '=', 'list_price')
                ]
        )
        if not items:
            self.env['product.pricelist.item'].create(
                    {
                        'base': 'list_price',#product_price_type_ids and product_price_type_ids[0].id,
                        'sequence': 1,
                        'name': product_template.name,
                        'product_tmpl_id': product_template.id,
                        'pricelist_id': self.id,
                        'fixed_price': new_price,
                        'price_discount':-1
                    }
            )
        else:
            for item in items:
                item.write(
                        {
                            'base': 'list_price',#product_price_type_ids and product_price_type_ids[0].id,
                            'sequence': 1,
                            'name': product_template.name,
                            'product_tmpl_id': product_template.id,
                            'pricelist_id': self.id,
                            'fixed_price': new_price,
                            'price_discount':-1
                        }
                )
        return True