def _get_analytic_journal(journal_type):
# Get the analytic journal
data = False
- if journal_type in ('sale', 'sale_refund'):
- data = obj_data.get_object_reference(cr, uid, 'account', 'analytic_journal_sale')
- elif journal_type in ('purchase', 'purchase_refund'):
- pass
- elif journal_type == 'general':
+ try:
+ if journal_type in ('sale', 'sale_refund'):
+ data = obj_data.get_object_reference(cr, uid, 'account', 'analytic_journal_sale')
+ elif journal_type in ('purchase', 'purchase_refund'):
+ data = obj_data.get_object_reference(cr, uid, 'account', 'exp')
+ elif journal_type == 'general':
+ pass
+ except ValueError:
pass
return data and data[1] or False
from openerp.osv import fields, osv
from openerp.tools.translate import _
+from openerp.tools.float_utils import float_round
import openerp.addons.decimal_precision as dp
class account_move_line_reconcile(osv.osv_memory):
credit += line.credit
debit += line.debit
account_id = line.account_id.id
- return {'trans_nbr': count, 'account_id': account_id, 'credit': credit, 'debit': debit, 'writeoff': debit - credit}
+ precision = self.pool['decimal.precision'].precision_get(cr, uid, 'Account')
+ writeoff = float_round(debit-credit, precision_digits=precision)
+ credit = float_round(credit, precision_digits=precision)
+ debit = float_round(debit, precision_digits=precision)
+ return {'trans_nbr': count, 'account_id': account_id, 'credit': credit, 'debit': debit, 'writeoff': writeoff}
def trans_rec_addendum_writeoff(self, cr, uid, ids, context=None):
return self.pool.get('account.move.line.reconcile.writeoff').trans_rec_addendum(cr, uid, ids, context)
</group>
<footer>
<button string="Reconcile" name="trans_rec_reconcile_full" type="object" default_focus="1" attrs="{'invisible':[('writeoff','!=',0)]}" class="oe_highlight"/>
- <button string="Reconcile With Write-Off" name="trans_rec_addendum_writeoff" type="object" attrs="{'invisible':[('writeoff','==',0)]}" class="oe_highlight"/>
- <button string="Partial Reconcile" name="trans_rec_reconcile_partial_reconcile" type="object" attrs="{'invisible':[('writeoff','==',0)]}" class="oe_highlight"/>
+ <button string="Reconcile With Write-Off" name="trans_rec_addendum_writeoff" type="object" attrs="{'invisible':[('writeoff','=',0)]}" class="oe_highlight"/>
+ <button string="Partial Reconcile" name="trans_rec_reconcile_partial_reconcile" type="object" attrs="{'invisible':[('writeoff','=',0)]}" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel"/>
</footer>
<filter name="open" string="In Progress" domain="[('state','in',('open','draft'))]" help="Contracts in progress (open, draft)"/>
<filter name="pending" string="To Renew" domain="[('state','=','pending')]" help="Pending contracts"/>
<filter name="closed" string="Closed" domain="[('state','=','close')]" help="Closed contracts"/>
- <filter name="cancelled" string="Cancelled" domain="[('state','=','cancel')]" help="Cancelled contracts"/>
+ <filter name="cancelled" string="Cancelled" domain="[('state','=','cancelled')]" help="Cancelled contracts"/>
<separator/>
<filter
string="Expired or consumed"
'name': fields.char('Name', size=64, required=True, select=1),
'note': fields.text('Note'),
'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic account'),
- 'account_asset_id': fields.many2one('account.account', 'Asset Account', required=True),
- 'account_depreciation_id': fields.many2one('account.account', 'Depreciation Account', required=True),
- 'account_expense_depreciation_id': fields.many2one('account.account', 'Depr. Expense Account', required=True),
+ 'account_asset_id': fields.many2one('account.account', 'Asset Account', required=True, domain=[('type','=','other')]),
+ 'account_depreciation_id': fields.many2one('account.account', 'Depreciation Account', required=True, domain=[('type','=','other')]),
+ 'account_expense_depreciation_id': fields.many2one('account.account', 'Depr. Expense Account', required=True, domain=[('type','=','other')]),
'journal_id': fields.many2one('account.journal', 'Journal', required=True),
'company_id': fields.many2one('res.company', 'Company', required=True),
'method': fields.selection([('linear','Linear'),('degressive','Degressive')], 'Computation Method', required=True, help="Choose the method to use to compute the amount of depreciation lines.\n"\
<para style="terp_default_8">
<font color="white"> </font>
</para>
- <para style="terp_default_9_followup_id">[[ format(get_text(o,data['form']['followup_id'])) ]]</para>
+ <pre style="terp_default_9_followup_id">[[ format(get_text(o,data['form']['followup_id'])) ]]</pre>
<para style="terp_default_9">
<font color="white"> </font>
</para>
filter = filter_format(conf['ldap_filter'], (login,))
try:
results = self.query(conf, filter)
+
+ # Get rid of (None, attrs) for searchResultReference replies
+ results = [i for i in results if i[0]]
if results and len(results) == 1:
dn = results[0][0]
conn = self.connect(conf)
new_id = get_real_ids(arg[2])
new_arg = (arg[0], arg[1], new_id)
new_args.append(new_arg)
- #offset, limit and count must be treated separately as we may need to deal with virtual ids
- if context.get('virtual_id', True):
- res = super(calendar_event, self).search(cr, uid, new_args, offset=0, limit=0, order=None, context=context, count=False)
- res = self.get_recurrent_ids(cr, uid, res, args, order=order, context=context)
- else:
- res = super(calendar_event, self).search(cr, uid, new_args, offset=0, limit=0, order=order, context=context, count=False)
+ if not context.get('virtual_id', True):
+ return super(calendar_event, self).search(cr, uid, new_args, offset=offset, limit=limit, order=order, context=context, count=count)
+
+ # offset, limit, order and count must be treated separately as we may need to deal with virtual ids
+ res = super(calendar_event, self).search(cr, uid, new_args, offset=0, limit=0, order=None, context=context, count=False)
+ res = self.get_recurrent_ids(cr, uid, res, args, order=order, context=context)
if count:
return len(res)
elif limit:
<field name="name">Meetings</field>
<field name="res_model">calendar.event</field>
<field name="view_mode">form,calendar,tree,gantt</field>
- <field name="view_id" ref="action_view_calendar_event_form"/>
+ <field name="view_id" ref="view_calendar_event_form"/>
</record>
self.precision_get.clear_cache(self)
for obj in self.pool.obj_list():
for colname, col in self.pool.get(obj)._columns.items():
- if isinstance(col, (fields.float, fields.function)):
+ if hasattr(col, 'digits_change'):
col.digits_change(cr)
- RegistryManager.signal_registry_change(cr.dbname)
+ RegistryManager.signal_caches_change(cr.dbname)
def create(self, cr, uid, data, context=None):
res = super(decimal_precision, self).create(cr, uid, data, context=context)
if path == '/' and mode in ('list', 'cwd'):
return (None, None, None )
+ if path == '..': path = self.cwd + '/..'
path = _to_unicode(os.path.normpath(path)) # again, for '/db/../ss'
if path == '.': path = ''
# create a mail_mail based on values, without attachments
values = self.generate_email(cr, uid, template_id, res_id, context=context)
- assert values.get('email_from'), 'email_from is missing or empty after template rendering, send_mail() cannot proceed'
-
+ if not values.get('email_from'):
+ raise osv.except_osv(_('Warning!'),_("Sender email is missing or empty after template rendering. Specify one to deliver your message"))
# process partner_to field that is a comma separated list of partner_ids -> recipient_ids
# NOTE: only usable if force_send is True, because otherwise the value is
# not stored on the mail_mail, and therefore lost -> fixed in v8
def post(self, cr, uid, message, to_session_id, technical=False, uuid=None, context=None):
assert_uuid(uuid)
my_id = self.pool.get('im.user').get_my_id(cr, uid, uuid)
- session = self.pool.get('im.session').browse(cr, uid, to_session_id, context)
- to_ids = [x.id for x in session.user_ids if x.id != my_id]
+ session_user_ids = self.pool.get('im.session').get_session_users(cr, uid, to_session_id, context=context).get("user_ids", [])
+ to_ids = [user_id for user_id in session_user_ids if user_id != my_id]
self.create(cr, openerp.SUPERUSER_ID, {"message": message, 'from_id': my_id,
'to_id': [(6, 0, to_ids)], 'session_id': to_session_id, 'technical': technical}, context=context)
notify_channel(cr, "im_channel", {'type': 'message', 'receivers': [my_id] + to_ids})
return res
_columns = {
- 'user_ids': fields.many2many('im.user'),
+ 'user_ids': fields.many2many('im.user', 'im_session_im_user_rel', 'im_session_id', 'im_user_id', 'Users'),
"name": fields.function(_calc_name, string="Name", type='char'),
}
}, context=context)
return self.read(cr, uid, session_id, context=context)
+ def get_session_users(self, cr, uid, session_id, context=None):
+ return self.read(cr, openerp.SUPERUSER_ID, session_id, ['user_ids'], context=context)
+
def add_to_session(self, cr, uid, session_id, user_id, uuid=None, context=None):
my_id = self.pool.get("im.user").get_my_id(cr, uid, uuid, context=context)
session = self.read(cr, uid, session_id, context=context)
return ['&', ('im_last_status', '=', True), ('im_last_status_update', '>', (current - delta).strftime(DEFAULT_SERVER_DATETIME_FORMAT))]
else:
return ['|', ('im_last_status', '=', False), ('im_last_status_update', '<=', (current - delta).strftime(DEFAULT_SERVER_DATETIME_FORMAT))]
-
+ # TODO: Remove fields arg in trunk. Also in im.js.
def search_users(self, cr, uid, text_search, fields, limit, context=None):
my_id = self.get_my_id(cr, uid, None, context)
group_employee = self.pool['ir.model.data'].get_object_reference(cr, uid, 'base', 'group_user')[1]
if len(found) < limit:
found += self.search(cr, uid, [["name", "ilike", text_search], ["id", "<>", my_id], ["uuid", "=", False], ["im_status", "=", False], ["id", "not in", found]],
order="name asc", limit=limit-len(found), context=context)
- users = self.read(cr, uid, found, fields, context=context)
+ users = self.read(cr,openerp.SUPERUSER_ID, found, ["name", "user_id", "uuid", "im_status"], context=context)
users.sort(key=lambda obj: found.index(obj['id']))
return users
continue
return res
+ def get_users(self, cr, uid, ids, context=None):
+ return self.read(cr,openerp.SUPERUSER_ID, ids, ["name", "im_status", "uuid"], context=context)
+
_columns = {
'name': fields.function(_get_name, type='char', size=200, string="Name", store=True, readonly=True),
'assigned_name': fields.char(string="Assigned Name", size=200, required=False),
('user_uniq', 'unique (user_id)', 'Only one chat user per OpenERP user.'),
('uuid_uniq', 'unique (uuid)', 'Chat identifier already used.'),
]
+
+class res_users(osv.osv):
+ _inherit = "res.users"
+
+ def _get_im_user(self, cr, uid, ids, field_name, arg, context=None):
+ result = dict.fromkeys(ids, False)
+ for index, im_user in enumerate(self.pool['im.user'].search_read(cr, uid, domain=[('user_id', 'in', ids)], fields=['name', 'user_id'], context=context)):
+ result[ids[index]] = im_user.get('user_id') and (im_user['user_id'][0], im_user['name']) or False
+ return result
+
+ _columns = {
+ 'im_user_id' : fields.function(_get_im_user, type='many2one', string="IM User", relation="im.user"),
+ }
<openerp>
<data>
<record id="message_rule_1" model="ir.rule">
- <field name="name">Can only read messages that you sent or messages sent to you</field>
+ <field name="name">Can only read messages from a session where user is</field>
<field name="model_id" ref="model_im_message"/>
<field name="groups" eval="[(6,0,[ref('base.group_user')])]"/>
- <field name="domain_force">["|", ('to_id.user_id', 'in', [user.id]), ('from_id.user_id', '=', user.id)]</field>
+ <field name="domain_force">[('session_id.user_ids', 'in', user.im_user_id.id)]</field>
<field name="perm_read" eval="1"/>
<field name="perm_write" eval="0"/>
<field name="perm_create" eval="0"/>
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
-access_im_message,im.message,model_im_message,base.group_user,1,0,1,0
+access_im_message,im.message,model_im_message,,1,0,1,0
access_im_user,im.user,model_im_user,,1,1,1,0
access_im_session,im.session,model_im_session,,1,0,0,0
\ No newline at end of file
search_changed: function(e) {
var users = new instance.web.Model("im.user");
var self = this;
+ // TODO: Remove fields arg in trunk. Also in im.js.
return this.user_search_dm.add(users.call("search_users", [this.get("current_search"), ["name", "user_id", "uuid", "im_status"],
USERS_LIMIT], {context:new instance.web.CompoundContext()})).then(function(users) {
var logged_users = _.filter(users, function(u) { return !!u.im_status; });
if (_.size(no_cache) === 0)
def = $.when();
else
- def = im_common.connection.model("im.user").call("read", [_.values(no_cache), []]).then(function(users) {
+ def = im_common.connection.model("im.user").call("get_users", [_.values(no_cache)]).then(function(users) {
self.add_to_user_cache(users);
});
return def.then(function() {
return self.chat_with_users(users);
});
},
- activate_session: function(session_id, focus) {
+ activate_session: function(session_id, focus, message) {
+ var self = this;
var conv = _.find(this.conversations, function(conv) {return conv.session_id == session_id;});
var def = $.when();
if (! conv) {
this.calc_positions();
this.trigger("new_conversation", conv);
}, this));
+ def = def.then(function(){
+ return self.load_history(conv, message);
+ });
}
if (focus) {
def = def.then(function() {
}
return def.then(function() {return conv});
},
- received_messages: function(messages) {
+ load_history: function(conv, message){
+ var self = this;
+ var domain = [["session_id", "=", conv.session_id]];
+ if (!_.isUndefined(message)){
+ domain.push(["date", "<", message.date]);
+ }
+ return im_common.connection.model("im.message").call("search_read", [domain, [], 0, 10]).then(function(messages){
+ messages.reverse();
+ var users = _.unique(_.map(messages, function(message){
+ return message.from_id[0];
+ }));
+ return self.ensure_users(users).then(function(){
+ return self.received_messages(messages, true);
+ });
+ });
+ },
+ received_messages: function(messages, seen) {
var self = this;
var defs = [];
var received = false;
+ if (_.isUndefined(seen)){
+ seen = false;
+ }
_.each(messages, function(message) {
if (! message.technical) {
- defs.push(self.activate_session(message.session_id[0]).then(function(conv) {
+ defs.push(self.activate_session(message.session_id[0], false, message).then(function(conv) {
received = self.my_id !== message.from_id[0];
return conv.received_message(message);
}));
}
});
return $.when.apply($, defs).then(function(){
- if (! self.get("window_focus") && received) {
+ if (! self.get("window_focus") && received && !seen) {
self.set("waiting_messages", self.get("waiting_messages") + messages.length);
self.ting.play();
self.create_ting();
refresh_users: function() {
var self = this;
var user_ids;
- return im_common.connection.model("im.session").call("read", [self.session_id]).then(function(session) {
+ return im_common.connection.model("im.session").call("get_session_users", [self.session_id]).then(function(session) {
user_ids = _.without(session.user_ids, self.c_manager.me.get("id"));
return self.c_manager.ensure_users(user_ids);
}).then(function(users) {
date = "" + zpad(date.getHours(), 2) + ":" + zpad(date.getMinutes(), 2);
var to_show = _.map(items, im_common.escape_keep_url);
this.last_bubble = $(openerp.qweb.render("im_common.conversation_bubble", {"items": to_show, "user": user, "time": date}));
- $(this.$(".oe_im_chatview_content").children()[0]).append(this.last_bubble);
+ $(this.$(".oe_im_chatview_conversation")).append(this.last_bubble);
this._go_bottom();
},
_go_bottom: function() {
All users are offline. They will receive your messages on their next connection.
</div>
<div class="oe_im_chatview_content">
- <div></div>
+ <div class="oe_im_chatview_conversation"></div>
</div>
<div class="oe_im_chatview_footer">
<input class="oe_im_chatview_input" t-att-placeholder="widget.inputPlaceholder" />
return users
def get_session(self, cr, uid, channel_id, uuid, context=None):
- my_id = self.pool.get("im.user").get_my_id(cr, uid, uuid, context=context)
- users = self.get_available_users(cr, uid, channel_id, context=context)
+ self.pool.get("im.user").get_my_id(cr, uid, uuid, context=context)
+ users = self.get_available_users(cr, openerp.SUPERUSER_ID, channel_id, context=context)
if len(users) == 0:
return False
user_id = random.choice(users).id
<field name="res_model">im.message</field>
<field name="view_mode">list</field>
<field name="domain">[('session_id.channel_id', '!=', None)]</field>
+ <field name="context">{'search_default_group_by_session_id': 1, 'search_default_group_by_date': 1, 'search_default_session_id': 1}</field>
</record>
<menuitem name="History" parent="im_livechat" id="history" action="action_history" groups="group_im_livechat_manager"/>
</field>
</record>
+ <record id="im_message_search" model="ir.ui.view">
+ <field name="name">im.message.search</field>
+ <field name="model">im.message</field>
+ <field name="arch" type="xml">
+ <search string="Search history">
+ <filter name="session_id" string="My Sessions" domain="[('session_id.user_ids','in', uid)]"/>
+ <field name="from_id"/>
+ <field name="to_id"/>
+ <group expand="0" string="Group By...">
+ <filter name="group_by_session_id" string="Session" domain="[]" context="{'group_by':'session_id'}"/>
+ <filter name="group_by_date" string="Date" domain="[]" context="{'group_by':'date'}"/>
+ </group>
+ </search>
+ </field>
+ </record>
+
</data>
</openerp>
access_ls_chann1,im_livechat.channel,model_im_livechat_channel,,1,0,0,0
access_ls_chann2,im_livechat.channel,model_im_livechat_channel,group_im_livechat,1,1,1,0
access_ls_chann3,im_livechat.channel,model_im_livechat_channel,group_im_livechat_manager,1,1,1,1
-access_ls_message_portal,im_livechat.im.message.portal,im.model_im_message,portal.group_portal,0,0,0,0
access_im_user_portal,im_livechat.im.user.portal,im.model_im_user,portal.group_portal,1,0,0,0
-access_ls_message,im_livechat.im.message,im.model_im_message,portal.group_anonymous,0,0,0,0
access_im_user,im_livechat.im.user,im.model_im_user,portal.group_anonymous,1,0,0,0
\ No newline at end of file
}
self.manager.activate_session(session_id, true).then(function(conv) {
if (self.options.defaultMessage) {
- conv.received_message({
- message: self.options.defaultMessage,
- date: openerp.datetime_to_str(new Date()),
- from_id: [conv.get("users")[0].get("id"), "Unknown"]
- });
+ setTimeout(function(){
+ conv.received_message({
+ message: self.options.defaultMessage,
+ date: openerp.datetime_to_str(new Date()),
+ from_id: [conv.get("users")[0].get("id"), "Unknown"]
+ });
+ },
+ 2500);
}
});
});
def copy_data(self, *args, **kwargs):
data = super(res_users, self).copy_data(*args, **kwargs)
- if data.get('alias_name'):
+ if data and data.get('alias_name'):
data['alias_name'] = data['login']
return data
mail_values['email_from'] = email_dict.pop('email_from')
# replies redirection: mass mailing only
if not wizard.same_thread:
- mail_values['reply_to'] = email_dict.pop('reply_to')
+ mail_values['reply_to'] = email_dict.pop('reply_to', None)
else:
- email_dict.pop('reply_to')
+ email_dict.pop('reply_to', None)
mail_values.update(email_dict)
# mass mailing without post: mail_mail values
if mass_mail_mode and not wizard.post:
"""
routing_obj = self.pool.get('mrp.routing')
factor = factor / (bom.product_efficiency or 1.0)
- max_rounding = max(bom.product_rounding, bom.product_uom.rounding)
- factor = rounding(factor, max_rounding)
- if factor < max_rounding:
- factor = max_rounding
+ factor = rounding(factor, bom.product_rounding)
+ if factor < bom.product_rounding:
+ factor = bom.product_rounding
result = []
result2 = []
phantom = False
# qty available for consume and produce
qty_avail = scheduled.product_qty - consumed_data.get(scheduled.product_id.id, 0.0)
- if qty_avail <= 0.0:
+ if float_compare(qty_avail, 0, precision_rounding=scheduled.product_id.uom_id.rounding) <= 0:
# there will be nothing to consume for this raw material
continue
# if qtys we have to consume is more than qtys available to consume
prod_name = scheduled.product_id.name_get()[0][1]
raise osv.except_osv(_('Warning!'), _('You are going to consume total %s quantities of "%s".\nBut you can only consume up to total %s quantities.') % (qty, prod_name, qty_avail))
- if qty <= 0.0:
+ if float_compare(qty, 0, precision_rounding=scheduled.product_id.uom_id.rounding) <= 0:
# we already have more qtys consumed than we need
continue
<field name="workcenter_id"/>
<field name="sequence"/>
<field name="cycle"/>
- <field name="hour"/>
+ <field name="hour" widget="float_time"/>
</group>
</form>
<tree string="Production Work Centers">
<field name="name"/>
<field name="workcenter_id"/>
<field name="cycle"/>
- <field name="hour"/>
+ <field name="hour" widget="float_time"/>
</tree>
</field>
</page>
<field name="name"/>
<field name="workcenter_id" widget="selection"/>
<field name="cycle"/>
- <field name="hour"/>
+ <field name="hour" widget="float_time"/>
<field name="state" />
</tree>
</field>
"""
mail_message = self.pool.get('mail.message')
model_obj = self.pool[model]
- msg = self.pool.get('mail.thread').message_parse(cr, uid, email)
- message_id = msg.get('message-id')
+ mail_thread_obj = self.pool.get('mail.thread')
+ msg = mail_thread_obj.message_parse(cr, uid, email)
+ message_id = msg.get('message_id')
mail_ids = mail_message.search(cr, uid, [('message_id', '=', message_id), ('res_id', '=', res_id), ('model', '=', model)])
if message_id and mail_ids:
mail_record = mail_message.browse(cr, uid, mail_ids)[0]
res_id = model_obj.message_process(cr, uid, model, email)
notify = _("Mail successfully pushed, a new %s has been created.") % model
else:
+ email_from = msg.get('email_from')
+ if not email_from:
+ author_id = False
+ else:
+ authors = mail_thread_obj.message_find_partner_from_emails(cr, uid, [res_id], [email_from])
+ author_id = authors and authors[0].get('partner_id') or False
+
model_obj.message_post(cr, uid, [res_id],
body=msg.get('body'),
subject=msg.get('subject'),
type='comment' if model == 'res.partner' else 'email',
parent_id=msg.get('parent_id'),
- attachments=msg.get('attachments'))
+ attachments=msg.get('attachments'),
+ message_id=message_id,
+ email_from=email_from,
+ author_id=author_id)
notify = _("Mail successfully pushed")
url = self._make_url(cr, uid, res_id, model)
return (model, res_id, url, notify)
ir_attachment_obj = self.pool.get('ir.attachment')
attach_ids = []
msg = self.pool.get('mail.thread').message_parse(cr, uid, headers)
- message_id = msg.get('message-id')
+ message_id = msg.get('message_id')
push_mail = self.push_message(cr, uid, model, headers, res_id)
res_id = push_mail[1]
model = push_mail[0]
attach_ids.append(ir_attachment_obj.create(cr, uid, vals))
mail_ids = mail_message.search(cr, uid, [('message_id', '=', message_id), ('res_id', '=', res_id), ('model', '=', model)])
if mail_ids:
- mail_message.write(cr, uid, mail_ids[0], {'attachment_ids': [(6, 0, attach_ids)], 'body': body, 'body_html': body_html})
+ mail_message.write(cr, uid, mail_ids[0], {'attachment_ids': [(6, 0, attach_ids)], 'body': body_html})
url = self._make_url(cr, uid, res_id, model)
return (model, res_id, url, notify)
else:
project_ids = project_pool.search(cr, uid, [('user_id','=',uid)], context=context)
- project_pool.schedule_phases(cr, uid, project_ids, context=context)
+ if project_ids:
+ project_pool.schedule_phases(cr, uid, project_ids, context=context)
return self._open_phases_list(cr, uid, data, context=context)
def _open_phases_list(self, cr, uid, data, context=None):
continue
if order_line.product_id.type in ('product', 'consu'):
move = stock_move.create(cr, uid, self._prepare_order_line_move(cr, uid, order, order_line, picking_id, context=context))
- if order_line.move_dest_id:
+ if order_line.move_dest_id and order_line.move_dest_id.state != 'done':
order_line.move_dest_id.write({'location_id': order.location_id.id})
todo_moves.append(move)
stock_move.action_confirm(cr, uid, todo_moves)
default.update({'state':'draft', 'move_ids':[],'invoiced':0,'invoice_lines':[]})
return super(purchase_order_line, self).copy_data(cr, uid, id, default, context)
+ def unlink(self, cr, uid, ids, context=None):
+ procurement_ids_to_cancel = []
+ for line in self.browse(cr, uid, ids, context=context):
+ if line.move_dest_id:
+ procurement_ids_to_cancel.extend(procurement.id for procurement in line.move_dest_id.procurements)
+ if procurement_ids_to_cancel:
+ self.pool['procurement.order'].action_cancel(cr, uid, procurement_ids_to_cancel)
+ return super(purchase_order_line, self).unlink(cr, uid, ids, context=context)
+
def onchange_product_uom(self, cr, uid, ids, pricelist_id, product_id, qty, uom_id,
partner_id, date_order=False, fiscal_position_id=False, date_planned=False,
name=False, price_unit=False, context=None):
<page string="Purchase Order">
<field name="order_line">
<tree string="Purchase Order Lines" editable="bottom">
- <field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,0,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)"/>
+ <field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,0,False,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)"/>
<field name="name"/>
<field name="date_planned"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
<sheet>
<group>
<group>
- <field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,0,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)"/>
+ <field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,0,False,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)"/>
<label for="product_qty"/>
<div>
<field name="product_qty" on_change="onchange_product_id(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)" class="oe_inline"/>
!python {model: procurement.order}: |
procurement = self.browse(cr, uid, ref('procurement_order_testcase0'))
assert procurement.purchase_id, 'RFQ should be generated!'
+-
+ I delete the line from the purchase order and check that the move and the procurement are cancelled
+-
+ !python {model: procurement.order}: |
+ procurement = self.browse(cr, uid, ref('procurement_order_testcase0'))
+ move = procurement.purchase_id.order_line[0].move_dest_id
+ procurement.purchase_id.order_line[0].unlink()
+ assert move.state == 'cancel', 'Move should be cancelled'
+ procurement.refresh()
+ assert procurement.state == 'cancel', 'Procurement should be cancelled'
<field name="product_id"
context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom}"
groups="base.group_user"
- on_change="product_id_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_uos_qty, product_uos, name, parent.partner_id, False, True, parent.date_order, False, parent.fiscal_position, False, context)"/>
+ on_change="product_id_change(parent.pricelist_id, product_id, product_uom_qty, False, product_uos_qty, False, name, parent.partner_id, False, True, parent.date_order, False, parent.fiscal_position, False, context)"/>
<label for="product_uom_qty"/>
<div>
<field
<field name="product_id"
context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom}"
groups="base.group_user"
- on_change="product_id_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_uos_qty, product_uos, name, parent.partner_id, False, True, parent.date_order, False, parent.fiscal_position, False, context)"/>
+ on_change="product_id_change(parent.pricelist_id, product_id, product_uom_qty, False, product_uos_qty, False, name, parent.partner_id, False, True, parent.date_order, False, parent.fiscal_position, False, context)"/>
<field name="name"/>
<field name="product_uom_qty"
context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom}"
<field name="product_id"
context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom}"
groups="base.group_user"
- on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, False, True, parent.date_order, product_packaging, parent.fiscal_position, False, context)"/>
+ on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,False,product_uos_qty,False,name,parent.partner_id, False, True, parent.date_order, product_packaging, parent.fiscal_position, False, context)"/>
</field>
<field name="product_uom_qty" position="replace">
<field context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom}"
stock_output_acc = datas.get('stock_output_account', False)
stock_input_acc = datas.get('stock_input_account', False)
journal_id = datas.get('stock_journal', False)
- product_obj=self.browse(cr, uid, ids, context=context)[0]
- account_valuation = product_obj.categ_id.property_stock_valuation_account_id
- account_valuation_id = account_valuation and account_valuation.id or False
- if not account_valuation_id: raise osv.except_osv(_('Error!'), _('Specify valuation Account for Product Category: %s.') % (product_obj.categ_id.name))
move_ids = []
loc_ids = location_obj.search(cr, uid,[('usage','=','internal')])
- for rec_id in ids:
+ for product in self.browse(cr, uid, ids, context=context):
+ if product.valuation != 'real_time':
+ continue
+ account_valuation = product.categ_id.property_stock_valuation_account_id
+ account_valuation_id = account_valuation and account_valuation.id or False
+ if not account_valuation_id: raise osv.except_osv(_('Error!'), _('Specify valuation Account for Product Category: %s.') % (product.categ_id.name))
for location in location_obj.browse(cr, uid, loc_ids, context=context):
c = context.copy()
c.update({
'compute_child': False
})
- product = self.browse(cr, uid, rec_id, context=c)
qty = product.qty_available
diff = product.standard_price - new_price
if not diff: raise osv.except_osv(_('Error!'), _("No difference between standard price and new price!"))
'debit': amount_diff,
'move_id': move_id
})
-
- self.write(cr, uid, rec_id, {'standard_price': new_price})
+ self.write(cr, uid, ids, {'standard_price': new_price})
return move_ids
quantity = move.product_qty
uos_qty = quantity / move_qty * move.product_uos_qty
- if quantity_rest > 0:
+ if float_compare(quantity_rest, 0, precision_rounding=move.product_id.uom_id.rounding):
default_val = {
'product_qty': quantity,
'product_uos_qty': uos_qty,