Skip to content

Commit

Permalink
IMP code of uom prices
Browse files Browse the repository at this point in the history
  • Loading branch information
jjscarafia committed Jan 14, 2016
1 parent 9100280 commit 77b11f7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 52 deletions.
32 changes: 17 additions & 15 deletions product_uom_prices/sale.py
Expand Up @@ -52,26 +52,28 @@ def product_id_change(
uom_id = product.uom_price_ids[0].uom_id.id
res['value'].update(
{'product_uom': uom_id})

# TODO REMOVE. we leave all this just in case we need
# si tenemos instalado el modulo "sale_stock", entonces odoo
# por defecto hace un hack y borrar la uom elegida y a uom y
# precio por defecto del producto en nuestro caso entonces
# termina quedando mal porque cambiamos la uom pero no el
# precio por eso forzamos el recalculo del precio
price = self.env['product.pricelist'].browse(
pricelist).with_context(
uom=uom_id, date=date_order,).price_get(
product.id, qty or 1.0, partner_id)[pricelist]
if price:
if self.env.uid == SUPERUSER_ID and self._context.get(
'company_id'):
taxes = product.taxes_id.filtered(
lambda r: r.company_id.id == self._context[
'company_id'])
else:
taxes = product.taxes_id
price = self.env['account.tax']._fix_tax_included_price(
price, taxes, res.get('value').get('tax_id'))
res['value'].update({'price_unit': price})
# price = self.env['product.pricelist'].browse(
# pricelist).with_context(
# uom=uom_id, date=date_order,).price_get(
# product.id, qty or 1.0, partner_id)[pricelist]
# if price:
# if self.env.uid == SUPERUSER_ID and self._context.get(
# 'company_id'):
# taxes = product.taxes_id.filtered(
# lambda r: r.company_id.id == self._context[
# 'company_id'])
# else:
# taxes = product.taxes_id
# price = self.env['account.tax']._fix_tax_included_price(
# price, taxes, res.get('value').get('tax_id'))
# res['value'].update({'price_unit': price})
# we do this because odoo overwrite view domain
if 'domain' not in res:
res['domain'] = {}
Expand Down
1 change: 0 additions & 1 deletion sale_stock_product_uom_prices/__openerp__.py
Expand Up @@ -36,7 +36,6 @@
'test': [],
'demo': [],
'data': [
'view/sale_view.xml',
],
'installable': True,
'auto_install': True,
Expand Down
21 changes: 0 additions & 21 deletions sale_stock_product_uom_prices/sale.py
Expand Up @@ -18,32 +18,11 @@ def product_id_change_with_wh(
uom=False, qty_uos=0, uos=False, name='', partner_id=False,
lang=False, update_tax=True, date_order=False, packaging=False,
fiscal_position=False, flag=False, warehouse_id=False):
# if uom:
# context
res = super(sale_order_line, self.with_context(
preserve_uom=uom)).product_id_change_with_wh(
pricelist, product, qty=qty, uom=uom,
qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id,
lang=lang, update_tax=update_tax, date_order=date_order,
packaging=packaging, fiscal_position=fiscal_position,
flag=flag, warehouse_id=warehouse_id)

# print 'res1', res
# if product:
# context_partner = {'lang': lang, 'partner_id': partner_id}
# product = self.env['product.product'].with_context(
# context_partner).browse(
# product)
# if (
# not uom and product.use_uom_prices and
# self.env.user.company_id.default_uom_prices
# ):
# res['value'].update(
# {'product_uom': product.uom_price_ids[0].uom_id.id})
# # we do this because odoo overwrite view domain
# if 'domain' not in res:
# res['domain'] = {}
# res['domain']['product_uom'] = [
# ('id', 'in', self.get_product_uoms(
# product).ids)]
return res
15 changes: 0 additions & 15 deletions sale_stock_product_uom_prices/view/sale_view.xml

This file was deleted.

0 comments on commit 77b11f7

Please sign in to comment.