[MERGE] forward port of branch 7.0 up to revid 9651 chs@openerp.com-20131127104459-jb77x7quwcvtifm7
bzr revid: dle@openerp.com-20131126171210-jovr7e7efehuq3s2 bzr revid: chs@openerp.com-20131127110046-4ow36dkuuyzgf1pl
This commit is contained in:
commit
6b05beecc1
|
@ -33,6 +33,7 @@
|
|||
min-width: 130px;
|
||||
}
|
||||
.openerp .oe_timesheet_weekly td input.oe_timesheet_weekly_input {
|
||||
padding-right: 2px !important;
|
||||
width: 40px;
|
||||
text-align: right;
|
||||
min-width: 0 !important;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
.oe_timesheet_first_col
|
||||
min-width: 130px
|
||||
td input.oe_timesheet_weekly_input
|
||||
padding-right: 2px !important
|
||||
width: 40px
|
||||
text-align: right
|
||||
min-width: 0 !important
|
||||
|
|
|
@ -12,12 +12,13 @@
|
|||
<button name="cancel" string="Cancel" type="object" states='outgoing'/>
|
||||
</header>
|
||||
<sheet>
|
||||
<field name="mail_message_id" required="0" invisible="1"/>
|
||||
<label for="subject" class="oe_edit_only"/>
|
||||
<h2><field name="subject"/></h2>
|
||||
<div style="vertical-align: top;">
|
||||
by <field name="author_id" class="oe_inline" string="User"/> on <field name="date" class="oe_inline"/>
|
||||
<button name="%(action_email_compose_message_wizard)d" string="Reply" type="action" icon="terp-mail-replied"
|
||||
context="{'default_composition_mode':'reply', 'default_parent_id': active_id}" states='received,sent,exception,cancel'/>
|
||||
context="{'default_composition_mode':'reply', 'default_parent_id': mail_message_id}" states='received,sent,exception,cancel'/>
|
||||
</div>
|
||||
<group>
|
||||
<field name="email_from"/>
|
||||
|
|
|
@ -336,20 +336,27 @@ class mail_thread(osv.AbstractModel):
|
|||
self.message_auto_subscribe(cr, uid, [thread_id], create_values.keys(), context=context, values=create_values)
|
||||
|
||||
# track values
|
||||
tracked_fields = self._get_tracked_fields(cr, uid, values.keys(), context=context)
|
||||
track_ctx = dict(context)
|
||||
if 'lang' not in track_ctx:
|
||||
track_ctx['lang'] = self.pool.get('res.users').browse(cr, uid, uid, context=context).lang
|
||||
tracked_fields = self._get_tracked_fields(cr, uid, values.keys(), context=track_ctx)
|
||||
if tracked_fields:
|
||||
initial_values = {thread_id: dict((item, False) for item in tracked_fields)}
|
||||
self.message_track(cr, uid, [thread_id], tracked_fields, initial_values, context=context)
|
||||
|
||||
self.message_track(cr, uid, [thread_id], tracked_fields, initial_values, context=track_ctx)
|
||||
return thread_id
|
||||
|
||||
def write(self, cr, uid, ids, values, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if isinstance(ids, (int, long)):
|
||||
ids = [ids]
|
||||
# Track initial values of tracked fields
|
||||
tracked_fields = self._get_tracked_fields(cr, uid, values.keys(), context=context)
|
||||
track_ctx = dict(context)
|
||||
if 'lang' not in track_ctx:
|
||||
track_ctx['lang'] = self.pool.get('res.users').browse(cr, uid, uid, context=context).lang
|
||||
tracked_fields = self._get_tracked_fields(cr, uid, values.keys(), context=track_ctx)
|
||||
if tracked_fields:
|
||||
records = self.browse(cr, uid, ids, context=context)
|
||||
records = self.browse(cr, uid, ids, context=track_ctx)
|
||||
initial_values = dict((this.id, dict((key, getattr(this, key)) for key in tracked_fields.keys())) for this in records)
|
||||
|
||||
# Perform write, update followers
|
||||
|
@ -358,7 +365,7 @@ class mail_thread(osv.AbstractModel):
|
|||
|
||||
# Perform the tracking
|
||||
if tracked_fields:
|
||||
self.message_track(cr, uid, ids, tracked_fields, initial_values, context=context)
|
||||
self.message_track(cr, uid, ids, tracked_fields, initial_values, context=track_ctx)
|
||||
return result
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
|
|
|
@ -834,7 +834,9 @@ openerp.mail = function (session) {
|
|||
// go to the parented message
|
||||
var message = this.parent_thread.parent_message;
|
||||
var parent_message = message.parent_id ? message.parent_thread.parent_message : message;
|
||||
var messages = [parent_message].concat(parent_message.get_childs());
|
||||
if(parent_message){
|
||||
var messages = [parent_message].concat(parent_message.get_childs());
|
||||
}
|
||||
} else if (this.options.emails_from_on_composer) {
|
||||
// get all wall messages if is not a mail.Wall
|
||||
_.each(this.options.root_thread.messages, function (msg) {messages.push(msg); messages.concat(msg.get_childs());});
|
||||
|
|
|
@ -194,7 +194,6 @@ class procurement_order(osv.osv):
|
|||
'company_id': orderpoint.company_id.id,
|
||||
'product_uom': orderpoint.product_uom.id,
|
||||
'location_id': orderpoint.location_id.id,
|
||||
'warehouse_id': orderpoint.warehouse_id.id,
|
||||
'procure_method': 'make_to_order',
|
||||
'origin': orderpoint.name}
|
||||
|
||||
|
|
|
@ -478,7 +478,7 @@ class purchase_order(osv.osv):
|
|||
if not acc_id:
|
||||
raise osv.except_osv(_('Error!'), _('Define expense account for this company: "%s" (id:%d).') % (po_line.product_id.name, po_line.product_id.id,))
|
||||
else:
|
||||
acc_id = property_obj.get(cr, uid, 'property_account_expense_categ', 'product.category').id
|
||||
acc_id = property_obj.get(cr, uid, 'property_account_expense_categ', 'product.category', context=context).id
|
||||
fpos = po_line.order_id.fiscal_position or False
|
||||
return fiscal_obj.map_account(cr, uid, fpos, acc_id)
|
||||
|
||||
|
@ -518,15 +518,23 @@ class purchase_order(osv.osv):
|
|||
:return: ID of created invoice.
|
||||
:rtype: int
|
||||
"""
|
||||
res = False
|
||||
|
||||
if context is None:
|
||||
context = {}
|
||||
journal_obj = self.pool.get('account.journal')
|
||||
inv_obj = self.pool.get('account.invoice')
|
||||
inv_line_obj = self.pool.get('account.invoice.line')
|
||||
|
||||
res = False
|
||||
uid_company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
|
||||
for order in self.browse(cr, uid, ids, context=context):
|
||||
context.pop('force_company', None)
|
||||
if order.company_id.id != uid_company_id:
|
||||
#if the company of the document is different than the current user company, force the company in the context
|
||||
#then re-do a browse to read the property fields for the good company.
|
||||
context['force_company'] = order.company_id.id
|
||||
order = self.browse(cr, uid, order.id, context=context)
|
||||
pay_acc_id = order.partner_id.property_account_payable.id
|
||||
journal_ids = journal_obj.search(cr, uid, [('type', '=','purchase'),('company_id', '=', order.company_id.id)], limit=1)
|
||||
journal_ids = journal_obj.search(cr, uid, [('type', '=', 'purchase'), ('company_id', '=', order.company_id.id)], limit=1)
|
||||
if not journal_ids:
|
||||
raise osv.except_osv(_('Error!'),
|
||||
_('Define purchase journal for this company: "%s" (id:%d).') % (order.company_id.name, order.company_id.id))
|
||||
|
@ -539,7 +547,7 @@ class purchase_order(osv.osv):
|
|||
inv_line_id = inv_line_obj.create(cr, uid, inv_line_data, context=context)
|
||||
inv_lines.append(inv_line_id)
|
||||
|
||||
po_line.write({'invoiced':True, 'invoice_lines': [(4, inv_line_id)]}, context=context)
|
||||
po_line.write({'invoiced': True, 'invoice_lines': [(4, inv_line_id)]}, context=context)
|
||||
|
||||
# get invoice data and create invoice
|
||||
inv_data = {
|
||||
|
@ -720,6 +728,7 @@ class purchase_order(osv.osv):
|
|||
'invoiced':False,
|
||||
'invoice_ids': [],
|
||||
'picking_ids': [],
|
||||
'partner_ref': '',
|
||||
'name': self.pool.get('ir.sequence').get(cr, uid, 'purchase.order'),
|
||||
})
|
||||
return super(purchase_order, self).copy(cr, uid, id, default, context)
|
||||
|
@ -1114,6 +1123,35 @@ class procurement_order(osv.osv):
|
|||
seller_delay = int(procurement.product_id.seller_delay)
|
||||
return schedule_date - relativedelta(days=seller_delay)
|
||||
|
||||
def _get_warehouse(self, procurement, user_company):
|
||||
"""
|
||||
Return the warehouse containing the procurment stock location (or one of it ancestors)
|
||||
If none match, returns then first warehouse of the company
|
||||
"""
|
||||
# TODO refactor the domain once we implement the "parent_of" domain operator
|
||||
# NOTE This method has been copied in the `purchase_requisition` module to ensure
|
||||
# retro-compatibility. This code duplication will be deleted in next stable version.
|
||||
# Do not forget to update both version in case of modification.
|
||||
company_id = (procurement.company_id or user_company).id
|
||||
domains = [
|
||||
[
|
||||
'&', ('company_id', '=', company_id),
|
||||
'|', '&', ('lot_stock_id.parent_left', '<', procurement.location_id.parent_left),
|
||||
('lot_stock_id.parent_right', '>', procurement.location_id.parent_right),
|
||||
('lot_stock_id', '=', procurement.location_id.id)
|
||||
],
|
||||
[('company_id', '=', company_id)]
|
||||
]
|
||||
|
||||
cr, uid = procurement._cr, procurement._uid
|
||||
context = procurement._context
|
||||
Warehouse = self.pool['stock.warehouse']
|
||||
for domain in domains:
|
||||
ids = Warehouse.search(cr, uid, domain, context=context)
|
||||
if ids:
|
||||
return ids[0]
|
||||
return False
|
||||
|
||||
def make_po(self, cr, uid, ids, context=None):
|
||||
""" Make purchase order from procurement
|
||||
@return: New created Purchase Orders procurement wise
|
||||
|
@ -1128,7 +1166,6 @@ class procurement_order(osv.osv):
|
|||
prod_obj = self.pool.get('product.product')
|
||||
acc_pos_obj = self.pool.get('account.fiscal.position')
|
||||
seq_obj = self.pool.get('ir.sequence')
|
||||
warehouse_obj = self.pool.get('stock.warehouse')
|
||||
for procurement in self.browse(cr, uid, ids, context=context):
|
||||
res_id = procurement.move_id.id
|
||||
partner = procurement.product_id.seller_id # Taken Main Supplier of Product of Procurement.
|
||||
|
@ -1136,7 +1173,6 @@ class procurement_order(osv.osv):
|
|||
partner_id = partner.id
|
||||
address_id = partner_obj.address_get(cr, uid, [partner_id], ['delivery'])['delivery']
|
||||
pricelist_id = partner.property_product_pricelist_purchase.id
|
||||
warehouse_id = warehouse_obj.search(cr, uid, [('company_id', '=', procurement.company_id.id or company.id)], context=context)
|
||||
uom_id = procurement.product_id.uom_po_id.id
|
||||
|
||||
qty = uom_obj._compute_qty(cr, uid, procurement.product_uom.id, procurement.product_qty, uom_id)
|
||||
|
@ -1175,7 +1211,7 @@ class procurement_order(osv.osv):
|
|||
'origin': procurement.origin,
|
||||
'partner_id': partner_id,
|
||||
'location_id': procurement.location_id.id,
|
||||
'warehouse_id': warehouse_id and warehouse_id[0] or False,
|
||||
'warehouse_id': self._get_warehouse(procurement, company),
|
||||
'pricelist_id': pricelist_id,
|
||||
'date_order': purchase_date.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
'company_id': procurement.company_id.id,
|
||||
|
|
|
@ -228,34 +228,69 @@ class product_product(osv.osv):
|
|||
|
||||
|
||||
class procurement_order(osv.osv):
|
||||
|
||||
_inherit = 'procurement.order'
|
||||
_columns = {
|
||||
'requisition_id' : fields.many2one('purchase.requisition','Latest Requisition')
|
||||
'requisition_id': fields.many2one('purchase.requisition', 'Latest Requisition')
|
||||
}
|
||||
|
||||
def _get_warehouse(self, procurement, user_company):
|
||||
"""
|
||||
Return the warehouse containing the procurment stock location (or one of it ancestors)
|
||||
If none match, returns then first warehouse of the company
|
||||
"""
|
||||
# NOTE This method is a copy of the one on the procurement.order defined in purchase
|
||||
# module. It's been copied to ensure it been always available, even if module
|
||||
# purchase is not up to date.
|
||||
# Do not forget to update both version in case of modification.
|
||||
company_id = (procurement.company_id or user_company).id
|
||||
domains = [
|
||||
[
|
||||
'&', ('company_id', '=', company_id),
|
||||
'|', '&', ('lot_stock_id.parent_left', '<', procurement.location_id.parent_left),
|
||||
('lot_stock_id.parent_right', '>', procurement.location_id.parent_right),
|
||||
('lot_stock_id', '=', procurement.location_id.id)
|
||||
],
|
||||
[('company_id', '=', company_id)]
|
||||
]
|
||||
|
||||
cr, uid = procurement._cr, procurement._uid
|
||||
context = procurement._context
|
||||
Warehouse = self.pool['stock.warehouse']
|
||||
for domain in domains:
|
||||
ids = Warehouse.search(cr, uid, domain, context=context)
|
||||
if ids:
|
||||
return ids[0]
|
||||
return False
|
||||
|
||||
def make_po(self, cr, uid, ids, context=None):
|
||||
res = {}
|
||||
requisition_obj = self.pool.get('purchase.requisition')
|
||||
warehouse_obj = self.pool.get('stock.warehouse')
|
||||
procurement = self.browse(cr, uid, ids, context=context)[0]
|
||||
if procurement.product_id.purchase_requisition:
|
||||
warehouse_id = warehouse_obj.search(cr, uid, [('company_id', '=', procurement.company_id.id or company.id)], context=context)
|
||||
res[procurement.id] = requisition_obj.create(cr, uid,
|
||||
{
|
||||
non_requisition = []
|
||||
for procurement in self.browse(cr, uid, ids, context=context):
|
||||
if procurement.product_id.purchase_requisition:
|
||||
user_company = self.pool['res.users'].browse(cr, uid, uid, context=context).company_id
|
||||
req = res[procurement.id] = requisition_obj.create(cr, uid, {
|
||||
'origin': procurement.origin,
|
||||
'date_end': procurement.date_planned,
|
||||
'warehouse_id':warehouse_id and warehouse_id[0] or False,
|
||||
'company_id':procurement.company_id.id,
|
||||
'line_ids': [(0,0,{
|
||||
'warehouse_id': self._get_warehouse(procurement, user_company),
|
||||
'company_id': procurement.company_id.id,
|
||||
'line_ids': [(0, 0, {
|
||||
'product_id': procurement.product_id.id,
|
||||
'product_uom_id': procurement.product_uom.id,
|
||||
'product_qty': procurement.product_qty
|
||||
|
||||
})],
|
||||
})],
|
||||
})
|
||||
self.write(cr,uid,[procurement.id],{'state': 'running','requisition_id': res[procurement.id]},context=context)
|
||||
else:
|
||||
res = super(procurement_order, self).make_po(cr, uid, ids, context=context)
|
||||
procurement.write({
|
||||
'state': 'running',
|
||||
'requisition_id': req
|
||||
})
|
||||
else:
|
||||
non_requisition.append(procurement.id)
|
||||
|
||||
if non_requisition:
|
||||
res.update(super(procurement_order, self).make_po(cr, uid, non_requisition, context=context))
|
||||
|
||||
return res
|
||||
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ class sale_order(osv.osv):
|
|||
'state': 'draft',
|
||||
'invoice_ids': [],
|
||||
'date_confirm': False,
|
||||
'client_order_ref': '',
|
||||
'name': self.pool.get('ir.sequence').get(cr, uid, 'sale.order'),
|
||||
})
|
||||
return super(sale_order, self).copy(cr, uid, id, default, context=context)
|
||||
|
|
Loading…
Reference in New Issue