[MERGE] forward port of branch 8.0 up to ee2b550
This commit is contained in:
@@ -606,14 +606,45 @@ class pos_order(osv.osv):
|
||||
'journal': ui_paymentline['journal_id'],
|
||||
}
|
||||
|
||||
# This deals with orders that belong to a closed session. In order
|
||||
# to recover from this we:
|
||||
# - assign the order to another compatible open session
|
||||
# - if that doesn't exist, create a new one
|
||||
def _get_valid_session(self, cr, uid, order, context=None):
|
||||
session = self.pool.get('pos.session')
|
||||
closed_session = session.browse(cr, uid, order['pos_session_id'], context=context)
|
||||
open_sessions = session.search(cr, uid, [('state', '=', 'opened'),
|
||||
('config_id', '=', closed_session.config_id.id),
|
||||
('user_id', '=', closed_session.user_id.id)],
|
||||
limit=1, order="start_at DESC", context=context)
|
||||
|
||||
if open_sessions:
|
||||
return open_sessions[0]
|
||||
else:
|
||||
new_session_id = session.create(cr, uid, {
|
||||
'config_id': closed_session.config_id.id,
|
||||
}, context=context)
|
||||
new_session = session.browse(cr, uid, new_session_id, context=context)
|
||||
|
||||
# bypass opening_control (necessary when using cash control)
|
||||
new_session.signal_workflow('open')
|
||||
|
||||
return new_session_id
|
||||
|
||||
def _process_order(self, cr, uid, order, context=None):
|
||||
session = self.pool.get('pos.session').browse(cr, uid, order['pos_session_id'], context=context)
|
||||
|
||||
if session.state == 'closing_control' or session.state == 'closed':
|
||||
session_id = self._get_valid_session(cr, uid, order, context=context)
|
||||
session = self.pool.get('pos.session').browse(cr, uid, session_id, context=context)
|
||||
order['pos_session_id'] = session_id
|
||||
|
||||
order_id = self.create(cr, uid, self._order_fields(cr, uid, order, context=context),context)
|
||||
journal_ids = set()
|
||||
for payments in order['statement_ids']:
|
||||
self.add_payment(cr, uid, order_id, self._payment_fields(cr, uid, payments[2], context=context), context=context)
|
||||
journal_ids.add(payments[2]['journal_id'])
|
||||
|
||||
session = self.pool.get('pos.session').browse(cr, uid, order['pos_session_id'], context=context)
|
||||
if session.sequence_number <= order['sequence_number']:
|
||||
session.write({'sequence_number': order['sequence_number'] + 1})
|
||||
session.refresh()
|
||||
|
||||
@@ -141,7 +141,7 @@
|
||||
</a>
|
||||
</li>
|
||||
<li t-if="submenu.child_id" t-attf-class="dropdown #{
|
||||
(submenu.url and submenu.url != '/' and any([request.httprequest.path == child.url.replace('/page/website.', '/page/') for child in submenu.child_id]) or
|
||||
(submenu.url and submenu.url != '/' and any([request.httprequest.path == child.url.replace('/page/website.', '/page/') for child in submenu.child_id if child.url]) or
|
||||
(submenu.url and request.httprequest.path == submenu.url.replace('/page/website.', '/page/'))) and 'active'
|
||||
}">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
access_test_inherit_mother,access_test_inherit_mother,model_test_inherit_mother,,1,1,1,1
|
||||
access_test_inherit_daughter,access_test_inherit_daughter,model_test_inherit_daughter,,1,1,1,1
|
||||
access_test_inherit_property,access_test_inherit_property,model_test_inherit_property,,1,1,1,1
|
||||
|
||||
|
@@ -78,3 +78,35 @@ class res_partner(models.Model):
|
||||
|
||||
# define a one2many field based on the inherited field partner_id
|
||||
daughter_ids = fields.One2many('test.inherit.daughter', 'partner_id')
|
||||
|
||||
|
||||
# Check the overriding of property fields by non-property fields.
|
||||
# Contribution by Adrien Peiffer (ACSONE).
|
||||
class test_inherit_property(models.Model):
|
||||
_name = 'test.inherit.property'
|
||||
|
||||
_columns = {
|
||||
'name': osv.fields.char('Name', required=True),
|
||||
'property_foo': osv.fields.property(string='Foo', type='integer'),
|
||||
'property_bar': osv.fields.property(string='Bar', type='integer'),
|
||||
}
|
||||
|
||||
class test_inherit_property(models.Model):
|
||||
_inherit = 'test.inherit.property'
|
||||
|
||||
@api.multi
|
||||
def _get_foo(self, name, arg):
|
||||
return dict.fromkeys(self.ids, 42)
|
||||
|
||||
_columns = {
|
||||
# override property_foo with an old-api function field
|
||||
'property_foo': osv.fields.function(_get_foo, type='integer', string='Foo'),
|
||||
}
|
||||
|
||||
# override property_bar with a new-api computed field
|
||||
property_bar = fields.Integer(compute='_compute_bar', company_dependent=False)
|
||||
|
||||
@api.multi
|
||||
def _compute_bar(self):
|
||||
for record in self:
|
||||
record.property_bar = 42
|
||||
|
||||
@@ -76,3 +76,20 @@ class test_inherits(common.TransactionCase):
|
||||
# search the partner from the daughter record
|
||||
partners = self.env['res.partner'].search([('daughter_ids', 'in', daughter.ids)])
|
||||
self.assertIn(partner_demo, partners)
|
||||
|
||||
|
||||
class test_override_property(common.TransactionCase):
|
||||
|
||||
def test_override_with_function_field(self):
|
||||
""" test overriding a property field by a function field """
|
||||
record = self.env['test.inherit.property'].create({'name': "Stuff"})
|
||||
# record.property_foo is not a property field
|
||||
self.assertEqual(record.property_foo, 42)
|
||||
self.assertFalse(type(record).property_foo.company_dependent)
|
||||
|
||||
def test_override_with_computed_field(self):
|
||||
""" test overriding a property field by a computed field """
|
||||
record = self.env['test.inherit.property'].create({'name': "Stuff"})
|
||||
# record.property_bar is not a property field
|
||||
self.assertEqual(record.property_bar, 42)
|
||||
self.assertFalse(type(record).property_bar.company_dependent)
|
||||
|
||||
@@ -1399,6 +1399,7 @@ class function(_column):
|
||||
def to_field_args(self):
|
||||
args = super(function, self).to_field_args()
|
||||
args['store'] = bool(self.store)
|
||||
args['company_dependent'] = False
|
||||
if self._type in ('float',):
|
||||
args['digits'] = self._digits_compute or self._digits
|
||||
elif self._type in ('selection', 'reference'):
|
||||
|
||||
Reference in New Issue
Block a user