[MERGE] forward port of branch 8.0 up to a0d44f9

This commit is contained in:
Christophe Simonis
2015-09-01 18:46:55 +02:00
5 changed files with 45 additions and 20 deletions
@@ -14,21 +14,21 @@ class TestPeriodState(TransactionCase):
self.wizard_period_close = self.registry('account.period.close')
self.wizard_period_close_id = self.wizard_period_close.create(cr, uid, {'sure': 1})
_, self.sale_journal_id = self.registry("ir.model.data").get_object_reference(cr, uid, "account", "sales_journal")
_, self.period_9_id = self.registry("ir.model.data").get_object_reference(cr, uid, "account", "period_9")
_, self.period_id = self.registry("ir.model.data").get_object_reference(cr, uid, "account", "period_0")
def test_period_state(self):
cr, uid = self.cr, self.uid
self.wizard_period_close.data_save(cr, uid, [self.wizard_period_close_id], {
'lang': 'en_US',
'active_model': 'account.period',
'active_ids': [self.period_9_id],
'active_ids': [self.period_id],
'tz': False,
'active_id': self.period_9_id
'active_id': self.period_id
})
with self.assertRaises(except_orm):
self.registry('account.move').create(cr, uid, {
'name': '/',
'period_id': self.period_9_id,
'period_id': self.period_id,
'journal_id': self.sale_journal_id,
'date': date.today(),
'line_id': [(0, 0, {
+22 -13
View File
@@ -259,6 +259,10 @@ class google_calendar(osv.AbstractModel):
if not self.get_need_synchro_attendee(cr, uid, context=context):
data.pop("attendees")
if isCreating:
other_google_ids = [other_att.google_internal_event_id for other_att in event.attendee_ids if other_att.google_internal_event_id]
if other_google_ids:
data["id"] = other_google_ids[0]
return data
def create_an_event(self, cr, uid, event, context=None):
@@ -428,7 +432,7 @@ class google_calendar(osv.AbstractModel):
if type == "write":
for oe_attendee in event['attendee_ids']:
if oe_attendee.email == partner_email:
calendar_attendee_obj.write(cr, uid, [oe_attendee.id], {'state': google_attendee['responseStatus'], 'google_internal_event_id': single_event_dict.get('id')}, context=context)
calendar_attendee_obj.write(cr, uid, [oe_attendee.id], {'state': google_attendee['responseStatus']}, context=context)
google_attendee['found'] = True
continue
@@ -447,7 +451,6 @@ class google_calendar(osv.AbstractModel):
partner_record.append((4, attendee.get('id')))
attendee['partner_id'] = attendee.pop('id')
attendee['state'] = google_attendee['responseStatus']
attendee['google_internal_event_id'] = single_event_dict.get('id')
attendee_record.append((0, 0, attendee))
for google_alarm in single_event_dict.get('reminders', {}).get('overrides', []):
alarm_id = calendar_alarm_obj.search(
@@ -626,17 +629,23 @@ class google_calendar(osv.AbstractModel):
('event_id.final_date', '>', self.get_minTime(cr, uid, context=context).strftime(DEFAULT_SERVER_DATETIME_FORMAT)),
], context=context_norecurrent)
for att in att_obj.browse(cr, uid, my_att_ids, context=context):
if not att.event_id.recurrent_id or att.event_id.recurrent_id == 0:
st, response, ask_time = self.create_an_event(cr, uid, att.event_id, context=context)
if status_response(st):
update_date = datetime.strptime(response['updated'], "%Y-%m-%dT%H:%M:%S.%fz")
ev_obj.write(cr, uid, att.event_id.id, {'oe_update_date': update_date})
new_ids.append(response['id'])
att_obj.write(cr, uid, [att.id for att in att.event_id.attendee_ids], {'google_internal_event_id': response['id'], 'oe_synchro_date': update_date})
cr.commit()
else:
_logger.warning("Impossible to create event %s. [%s] Enable DEBUG for response detail.", att.event_id.id, st)
_logger.debug("Response : %s" % response)
other_google_ids = [other_att.google_internal_event_id for other_att in att.event_id.attendee_ids if other_att.google_internal_event_id and other_att.id != att.id]
for other_google_id in other_google_ids:
if self.get_one_event_synchro(cr, uid, other_google_id, context=context):
att_obj.write(cr, uid, [att.id], {'google_internal_event_id': other_google_id})
break
else:
if not att.event_id.recurrent_id or att.event_id.recurrent_id == 0:
st, response, ask_time = self.create_an_event(cr, uid, att.event_id, context=context)
if status_response(st):
update_date = datetime.strptime(response['updated'], "%Y-%m-%dT%H:%M:%S.%fz")
ev_obj.write(cr, uid, att.event_id.id, {'oe_update_date': update_date})
new_ids.append(response['id'])
att_obj.write(cr, uid, [att.id], {'google_internal_event_id': response['id'], 'oe_synchro_date': update_date})
cr.commit()
else:
_logger.warning("Impossible to create event %s. [%s] Enable DEBUG for response detail.", att.event_id.id, st)
_logger.debug("Response : %s" % response)
return new_ids
def get_context_no_virtual(self, context):
+4 -2
View File
@@ -54,7 +54,8 @@
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.order</field>
<field name="view_mode">tree,form</field>
<field name="context">{"search_default_draft":1}</field>
<field name="domain">[('state','in',('draft','sent','cancel'))]</field>
<field name="context">{}</field>
<field name="search_view_id" ref="sale.view_sales_order_filter"/>
<field name="help">We haven't sent you any quotation.</field>
</record>
@@ -65,7 +66,8 @@
<field name="res_model">sale.order</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="sale.view_sales_order_filter"/>
<field name="context">{"search_default_sales":1}</field>
<field name="domain">[('state', 'not in', ('draft', 'sent', 'cancel'))]</field>
<field name="context">{}</field>
<field name="help">We haven't sent you any sales order.</field>
</record>
+14
View File
@@ -21,6 +21,7 @@
import datetime
import openerp
from openerp import api, models
from openerp.osv import fields, osv
class stock_production_lot(osv.osv):
@@ -75,6 +76,19 @@ class stock_production_lot(osv.osv):
}
# Onchange added in new api to avoid having to change views
class StockProductionLot(models.Model):
_inherit = 'stock.production.lot'
@api.onchange('product_id')
def _onchange_product(self):
defaults = self.with_context(
product_id=self.product_id.id).default_get(
['life_date', 'use_date', 'removal_date', 'alert_date'])
for field, value in defaults.items():
setattr(self, field, value)
class stock_quant(osv.osv):
_inherit = 'stock.quant'
+1 -1
View File
@@ -285,7 +285,7 @@ class stock_move(osv.osv):
average_valuation_price += q.qty * q.cost
average_valuation_price = average_valuation_price / move.product_qty
# Write the standard price, as SUPERUSER_ID because a warehouse manager may not have the right to write on products
ctx = dict(context, force_company=move.company_id.id)
ctx = dict(context or {}, force_company=move.company_id.id)
product_obj.write(cr, SUPERUSER_ID, [move.product_id.id], {'standard_price': average_valuation_price}, context=ctx)
self.write(cr, uid, [move.id], {'price_unit': average_valuation_price}, context=context)