[MERGE] Forward-port of saas-3 bugfixes up to 9f0ecb3

This commit is contained in:
Olivier Dony 2014-06-12 13:52:35 +02:00
commit ad4c6caecf
12 changed files with 1509 additions and 1423 deletions

View File

@ -580,7 +580,14 @@ class account_account(osv.osv):
pass pass
if name: if name:
if operator not in expression.NEGATIVE_TERM_OPERATORS: if operator not in expression.NEGATIVE_TERM_OPERATORS:
ids = self.search(cr, user, ['|', ('code', '=like', name+"%"), '|', ('shortcut', '=', name), ('name', operator, name)]+args, limit=limit) plus_percent = lambda n: n+'%'
code_op, code_conv = {
'ilike': ('=ilike', plus_percent),
'like': ('=like', plus_percent),
}.get(operator, (operator, lambda n: n))
ids = self.search(cr, user, ['|', ('code', code_op, code_conv(name)), '|', ('shortcut', '=', name), ('name', operator, name)]+args, limit=limit)
if not ids and len(name.split()) >= 2: if not ids and len(name.split()) >= 2:
#Separating code and name of account for searching #Separating code and name of account for searching
operand1,operand2 = name.split(' ',1) #name can contain spaces e.g. OpenERP S.A. operand1,operand2 = name.split(' ',1) #name can contain spaces e.g. OpenERP S.A.
@ -2913,7 +2920,7 @@ class account_fiscal_position_template(osv.osv):
'chart_template_id': fields.many2one('account.chart.template', 'Chart Template', required=True), 'chart_template_id': fields.many2one('account.chart.template', 'Chart Template', required=True),
'account_ids': fields.one2many('account.fiscal.position.account.template', 'position_id', 'Account Mapping'), 'account_ids': fields.one2many('account.fiscal.position.account.template', 'position_id', 'Account Mapping'),
'tax_ids': fields.one2many('account.fiscal.position.tax.template', 'position_id', 'Tax Mapping'), 'tax_ids': fields.one2many('account.fiscal.position.tax.template', 'position_id', 'Tax Mapping'),
'note': fields.text('Notes', translate=True), 'note': fields.text('Notes'),
} }
def generate_fiscal_position(self, cr, uid, chart_temp_id, tax_template_ref, acc_template_ref, company_id, context=None): def generate_fiscal_position(self, cr, uid, chart_temp_id, tax_template_ref, acc_template_ref, company_id, context=None):

View File

@ -565,6 +565,9 @@ class account_move_line(osv.osv):
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'account_move_line_journal_id_period_id_index\'') cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'account_move_line_journal_id_period_id_index\'')
if not cr.fetchone(): if not cr.fetchone():
cr.execute('CREATE INDEX account_move_line_journal_id_period_id_index ON account_move_line (journal_id, period_id)') cr.execute('CREATE INDEX account_move_line_journal_id_period_id_index ON account_move_line (journal_id, period_id)')
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = %s', ('account_move_line_date_id_index',))
if not cr.fetchone():
cr.execute('CREATE INDEX account_move_line_date_id_index ON account_move_line (date DESC, id desc)')
return res return res
def _check_no_view(self, cr, uid, ids, context=None): def _check_no_view(self, cr, uid, ids, context=None):

View File

@ -33,7 +33,7 @@ class account_fiscal_position(osv.osv):
'company_id': fields.many2one('res.company', 'Company'), 'company_id': fields.many2one('res.company', 'Company'),
'account_ids': fields.one2many('account.fiscal.position.account', 'position_id', 'Account Mapping'), 'account_ids': fields.one2many('account.fiscal.position.account', 'position_id', 'Account Mapping'),
'tax_ids': fields.one2many('account.fiscal.position.tax', 'position_id', 'Tax Mapping'), 'tax_ids': fields.one2many('account.fiscal.position.tax', 'position_id', 'Tax Mapping'),
'note': fields.text('Notes', translate=True), 'note': fields.text('Notes'),
} }
_defaults = { _defaults = {

View File

@ -214,6 +214,7 @@ class base_action_rule(osv.osv):
""" Wrap the methods `create` and `write` of the models specified by """ Wrap the methods `create` and `write` of the models specified by
the rules given by `ids` (or all existing rules if `ids` is `None`.) the rules given by `ids` (or all existing rules if `ids` is `None`.)
""" """
updated = False
if ids is None: if ids is None:
ids = self.search(cr, SUPERUSER_ID, []) ids = self.search(cr, SUPERUSER_ID, [])
for action_rule in self.browse(cr, SUPERUSER_ID, ids): for action_rule in self.browse(cr, SUPERUSER_ID, ids):
@ -223,20 +224,21 @@ class base_action_rule(osv.osv):
model_obj.create = self._wrap_create(model_obj.create, model) model_obj.create = self._wrap_create(model_obj.create, model)
model_obj.write = self._wrap_write(model_obj.write, model) model_obj.write = self._wrap_write(model_obj.write, model)
model_obj.base_action_ruled = True model_obj.base_action_ruled = True
return True updated = True
return updated
def create(self, cr, uid, vals, context=None): def create(self, cr, uid, vals, context=None):
res_id = super(base_action_rule, self).create(cr, uid, vals, context=context) res_id = super(base_action_rule, self).create(cr, uid, vals, context=context)
self._register_hook(cr, [res_id]) if self._register_hook(cr, [res_id]):
openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname) openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname)
return res_id return res_id
def write(self, cr, uid, ids, vals, context=None): def write(self, cr, uid, ids, vals, context=None):
if isinstance(ids, (int, long)): if isinstance(ids, (int, long)):
ids = [ids] ids = [ids]
super(base_action_rule, self).write(cr, uid, ids, vals, context=context) super(base_action_rule, self).write(cr, uid, ids, vals, context=context)
self._register_hook(cr, ids) if self._register_hook(cr, ids):
openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname) openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname)
return True return True
def onchange_model_id(self, cr, uid, ids, model_id, context=None): def onchange_model_id(self, cr, uid, ids, model_id, context=None):
@ -266,7 +268,10 @@ class base_action_rule(osv.osv):
action_ids = self.search(cr, uid, action_dom, context=context) action_ids = self.search(cr, uid, action_dom, context=context)
for action in self.browse(cr, uid, action_ids, context=context): for action in self.browse(cr, uid, action_ids, context=context):
now = datetime.now() now = datetime.now()
last_run = get_datetime(action.last_run) if action.last_run else False if action.last_run:
last_run = get_datetime(action.last_run)
else:
last_run = datetime.utcfromtimestamp(0)
# retrieve all the records that satisfy the action's condition # retrieve all the records that satisfy the action's condition
model = self.pool[action.model_id.model] model = self.pool[action.model_id.model]
@ -297,11 +302,16 @@ class base_action_rule(osv.osv):
if not record_dt: if not record_dt:
continue continue
action_dt = self._check_delay(cr, uid, action, record, record_dt, context=context) action_dt = self._check_delay(cr, uid, action, record, record_dt, context=context)
if last_run and (last_run <= action_dt < now) or (action_dt < now): if last_run <= action_dt < now:
try: try:
context = dict(context or {}, action=True)
self._process(cr, uid, action, [record.id], context=context) self._process(cr, uid, action, [record.id], context=context)
except Exception: except Exception:
import traceback import traceback
_logger.error(traceback.format_exc()) _logger.error(traceback.format_exc())
action.write({'last_run': now.strftime(DEFAULT_SERVER_DATETIME_FORMAT)}) action.write({'last_run': now.strftime(DEFAULT_SERVER_DATETIME_FORMAT)})
if automatic:
# auto-commit for batch processing
cr.commit()

View File

@ -10,7 +10,7 @@
<field eval="False" name="doall"/> <field eval="False" name="doall"/>
<field eval="'base.action.rule'" name="model"/> <field eval="'base.action.rule'" name="model"/>
<field eval="'_check'" name="function"/> <field eval="'_check'" name="function"/>
<field eval="'()'" name="args"/> <field eval="'(True,)'" name="args"/>
</record> </record>
</data> </data>

View File

@ -41,7 +41,9 @@ invoices from picking, OpenERP is able to add and compute the shipping line.
'delivery_data.xml' 'delivery_data.xml'
], ],
'demo': ['delivery_demo.xml'], 'demo': ['delivery_demo.xml'],
'test': ['test/delivery_cost.yml'], 'test': ['test/delivery_cost.yml',
'test/delivery_chained_pickings.yml',
],
'installable': True, 'installable': True,
'auto_install': False, 'auto_install': False,
'images': ['images/1_delivery_method.jpeg','images/2_delivery_pricelist.jpeg'], 'images': ['images/1_delivery_method.jpeg','images/2_delivery_pricelist.jpeg'],

View File

@ -166,6 +166,17 @@ class stock_move(osv.osv):
} }
return res return res
def _prepare_chained_picking(self, cr, uid, picking_name, picking, picking_type, moves_todo, context=None):
values = super(stock_move, self)._prepare_chained_picking(cr, uid, picking_name, picking, picking_type, moves_todo, context=context)
if picking.carrier_id:
values['carrier_id'] = picking.carrier_id.id
values['volume'] = picking.volume
values['weight'] = picking.weight
values['weight_net'] = picking.weight_net
values['carrier_tracking_ref'] = picking.carrier_tracking_ref
values['number_of_packages'] = picking.number_of_packages
return values
_columns = { _columns = {
'weight': fields.function(_cal_move_weight, type='float', string='Weight', digits_compute= dp.get_precision('Stock Weight'), multi='_cal_move_weight', 'weight': fields.function(_cal_move_weight, type='float', string='Weight', digits_compute= dp.get_precision('Stock Weight'), multi='_cal_move_weight',
store={ store={

View File

@ -0,0 +1,50 @@
-
I setup product and locations
-
!record {model: stock.location, id: dest_chained_location}:
name: DestChainedLocation
usage: internal
-
!record {model: stock.location, id: source_chained_location}:
name: Source Chained Location
chained_auto_packing: auto
chained_location_type: fixed
usage: internal
chained_location_id: dest_chained_location
-
I create a picking to location_convenience_shop, which is chained with location_refrigerator
-
!record {model: stock.picking, id: shipment_with_delivery}:
type: internal
carrier_id: delivery.delivery_carrier
volume: 42
carrier_tracking_ref: FDX123
number_of_packages: 7
-
I add a move in the picking
-
!record {model: stock.move, id: icecream_move}:
picking_id: shipment_with_delivery
product_id: product_product_delivery
product_uom: product.product_uom_kgm
product_qty: 130.0
location_id: stock.stock_location_suppliers
location_dest_id: source_chained_location
-
I confirm the picking
-
!workflow {model: stock.picking, action: button_confirm, ref: shipment_with_delivery}
-
I check that the delivery fields have been propagated to the chained picking
-
!python {model: stock.move}: |
original_move = self.browse(cr, uid, ref('icecream_move'), context=context)
original_picking = original_move.picking_id
chained_move = original_move.move_dest_id
chained_picking = chained_move.picking_id
assert chained_picking.carrier_tracking_ref == original_picking.carrier_tracking_ref, 'no propagation of carrier_tracking_ref'
assert chained_picking.carrier_id == original_picking.carrier_id, 'no propagation of carrier_id'
assert chained_picking.volume == original_picking.volume, 'no propagation of volume'
assert chained_picking.weight == original_picking.weight, 'no propagation of weight'
assert chained_picking.weight_net == original_picking.weight_net, 'no propagation of weight'

View File

@ -134,7 +134,7 @@
</page> </page>
<page string="Attendances" groups="base.group_hr_attendance"> <page string="Attendances" groups="base.group_hr_attendance">
<group> <group>
<field context="{'employee_id': employee_id, 'user_id':user_id}" name="attendances_ids" nolabel="1"> <field context="{'default_employee_id': employee_id, 'user_id':user_id}" name="attendances_ids" nolabel="1">
<tree string="Attendances" editable="bottom"> <tree string="Attendances" editable="bottom">
<field name="name"/> <field name="name"/>
<field name="action"/> <field name="action"/>

File diff suppressed because it is too large Load Diff

View File

@ -72,6 +72,7 @@ class account_fiscal_position(osv.osv):
_inherit = 'account.fiscal.position' _inherit = 'account.fiscal.position'
_columns = { _columns = {
'name': fields.char('Fiscal Position', size=64, required=True, translate=True), 'name': fields.char('Fiscal Position', size=64, required=True, translate=True),
'note': fields.text('Notes', translate=True),
} }
@ -79,6 +80,7 @@ class account_fiscal_position_template(osv.osv):
_inherit = 'account.fiscal.position.template' _inherit = 'account.fiscal.position.template'
_columns = { _columns = {
'name': fields.char('Fiscal Position Template', size=64, required=True, translate=True), 'name': fields.char('Fiscal Position Template', size=64, required=True, translate=True),
'note': fields.text('Notes', translate=True),
} }

View File

@ -122,7 +122,8 @@ class sale_order(osv.osv):
('shipping_except', 'Shipping Exception'), ('shipping_except', 'Shipping Exception'),
('invoice_except', 'Invoice Exception'), ('invoice_except', 'Invoice Exception'),
('done', 'Done'), ('done', 'Done'),
], 'Status', readonly=True,help="Gives the status of the quotation or sales order.\ ], 'Status', readonly=True, track_visibility='onchange',
help="Gives the status of the quotation or sales order.\
\nThe exception status is automatically set when a cancel operation occurs \ \nThe exception status is automatically set when a cancel operation occurs \
in the invoice validation (Invoice Exception) or in the picking list process (Shipping Exception).\nThe 'Waiting Schedule' status is set when the invoice is confirmed\ in the invoice validation (Invoice Exception) or in the picking list process (Shipping Exception).\nThe 'Waiting Schedule' status is set when the invoice is confirmed\
but waiting for the scheduler to run on the order date.", select=True), but waiting for the scheduler to run on the order date.", select=True),