Skip to content

Commit

Permalink
[MERGE] Forward-port 7.0 up to 9411a2d
Browse files Browse the repository at this point in the history
  • Loading branch information
odony committed Aug 1, 2014
2 parents b20636e + 9411a2d commit 5a0a500
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
9 changes: 7 additions & 2 deletions addons/product_visible_discount/product_visible_discount.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,15 @@ def get_real_price(res_dict, product_id, qty, uom, pricelist):
list_price = pricelist_obj.price_get(cr, uid, [pricelist],
product.id, qty or 1.0, partner_id, {'uom': uom,'date': date_order })

pricelists = pricelist_obj.read(cr,uid,[pricelist],['visible_discount'])
so_pricelist = pricelist_obj.browse(cr, uid, pricelist, context=context)

new_list_price = get_real_price(list_price, product.id, qty, uom, pricelist)
if len(pricelists)>0 and pricelists[0]['visible_discount'] and list_price[pricelist] != 0 and new_list_price != 0:
if so_pricelist.visible_discount and list_price[pricelist] != 0 and new_list_price != 0:
if so_pricelist.currency_id.id != product.company_id.currency_id.id:
# new_list_price is in company's currency while price in pricelist currency
new_list_price = self.pool['res.currency'].compute(cr, uid,
product.company_id.currency_id.id, so_pricelist.currency_id.id,
new_list_price, context=context)
discount = (new_list_price - price) / new_list_price * 100
if discount > 0:
result['price_unit'] = new_list_price
Expand Down
5 changes: 3 additions & 2 deletions openerp/addons/base/res/res_partner_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<group col="4">
<field name="name"/>
<field name="shortcut"/>
<field name="domain"/>
</group>
</form>
</field>
Expand Down Expand Up @@ -183,8 +184,8 @@
<field name="fax"/>
<field name="user_ids" invisible="1"/>
<field name="email" widget="email" attrs="{'required': [('user_ids','!=', [])]}"/>
<field name="title" domain="[('domain', '=', 'contact')]"
options='{"no_open": True}' attrs="{'invisible': [('is_company','=', True)]}" />
<field name="title" domain="[('domain','=','contact')]" options='{"no_open": True}' attrs="{'invisible': [('is_company','=',True)]}" context="{'default_domain': 'contact'}"/>
<field name="title" domain="[('domain','=','partner')]" options='{"no_open": True}' attrs="{'invisible': [('is_company','=',False)]}" context="{'default_domain': 'partner'}"/>
</group>
</group>

Expand Down
13 changes: 12 additions & 1 deletion openerp/osv/orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,16 @@ def load(self, cr, uid, fields, data, context=None):
# Failed to write, log to messages, rollback savepoint (to
# avoid broken transaction) and keep going
cr.execute('ROLLBACK TO SAVEPOINT model_load_save')
except Exception, e:
message = (_('Unknown error during import:') +
u' %s: %s' % (type(e), unicode(e)))
moreinfo = _('Resolve other errors first')
messages.append(dict(info, type='error',
message=message,
moreinfo=moreinfo))
# Failed for some reason, perhaps due to invalid data supplied,
# rollback savepoint and keep going
cr.execute('ROLLBACK TO SAVEPOINT model_load_save')
if any(message['type'] == 'error' for message in messages):
cr.execute('ROLLBACK TO SAVEPOINT model_load')
ids = False
Expand Down Expand Up @@ -4038,14 +4048,15 @@ def create(self, cr, user, vals, context=None):
self._transient_vacuum(cr, user)

self.check_access_rights(cr, user, 'create')

vals = self._add_missing_default_values(cr, user, vals, context)

if self._log_access:
for f in LOG_ACCESS_COLUMNS:
if vals.pop(f, None) is not None:
_logger.warning(
'Field `%s` is not allowed when creating the model `%s`.',
f, self._name)
vals = self._add_missing_default_values(cr, user, vals, context)

tocreate = {}
for v in self._inherits:
Expand Down

0 comments on commit 5a0a500

Please sign in to comment.