From 9cc171f3ef30a2df9ee3598595e29e1245437abd Mon Sep 17 00:00:00 2001 From: fabian Date: Tue, 1 Dec 2009 15:54:18 +0100 Subject: [PATCH] [REM] Removed company wise prices in product (it should use pricelist instead) [ADD] Added company_id fields in multiple models [ADD] Added multicompany management for invoice, sale, mrp and stock (it now passes the company_id from ressource to ressource) [FIX] Fixed default company method [ADD] Added multicompany rules to demo datas bzr revid: fabian@fabian-openerp-20091201145418-upu1kghhvrk4yuzy --- addons/account/account.py | 5 +- addons/account/account_move_line.py | 2 +- addons/account/invoice.py | 3 + addons/mrp/mrp.py | 13 +- addons/multi_company/multi_company.py | 4 +- addons/multi_company/multi_company_demo.xml | 133 +++++++++++++++++++- addons/product/product.py | 109 +--------------- addons/product/product_view.xml | 56 --------- addons/product/security/ir.model.access.csv | 2 - addons/project/project.py | 6 +- addons/project_mrp/mrp.py | 3 +- addons/purchase/purchase.py | 8 +- addons/sale/sale.py | 10 +- addons/stock/stock.py | 5 +- 14 files changed, 177 insertions(+), 182 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 02f79a6dfc5..73c42b4f863 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -320,7 +320,8 @@ class account_account(osv.osv): 'company_id': _default_company, 'active': lambda *a: True, 'check_history': lambda *a: True, - 'currency_mode': lambda *a: 'current' + 'currency_mode': lambda *a: 'current', + 'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'account.account', c), } def _check_recursion(self, cr, uid, ids): @@ -781,7 +782,7 @@ class account_move(osv.osv): ('journal_pur_voucher','Journal Purchase'), ('journal_voucher','Journal Voucher'), ],'Type', readonly=True, select=True, states={'draft':[('readonly',False)]}), - 'company_id': fields.many2one('res.company', 'Company', required=True), + 'company_id': fields.related('journal_id','company_id',type='many2one',relation='res.company',string='Company'), } _defaults = { 'name': lambda *a: '/', diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index cc1f1fcd3b0..04e695248db 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -388,7 +388,7 @@ class account_move_line(osv.osv): 'analytic_account_id' : fields.many2one('account.analytic.account', 'Analytic Account'), #TODO: remove this 'amount_taxed':fields.float("Taxed Amount",digits=(16,int(tools.config['price_accuracy']))), - 'company_id': fields.related('move_id','company_id',type='many2one',object='res.company',string='Company') + 'company_id': fields.related('account_id','company_id',type='many2one',object='res.company',string='Company') } diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 3fe324bd69c..4a3298ba5b9 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -989,6 +989,7 @@ class account_invoice(osv.osv): 'date': date, 'currency_id':currency_id, 'amount_currency':amount_currency and direction * amount_currency or 0.0, + 'company_id': invoice.company_id.id, } l2 = { 'debit': direction * pay_amount<0 and - direction * pay_amount, @@ -999,6 +1000,7 @@ class account_invoice(osv.osv): 'date': date, 'currency_id':currency_id, 'amount_currency':amount_currency and - direction * amount_currency or 0.0, + 'company_id': invoice.company_id.id, } if not name: @@ -1295,6 +1297,7 @@ class account_invoice_tax(osv.osv): 'base_amount': fields.float('Base Code Amount', digits=(16,int(config['price_accuracy']))), 'tax_code_id': fields.many2one('account.tax.code', 'Tax Code', help="The tax basis of the tax declaration."), 'tax_amount': fields.float('Tax Code Amount', digits=(16,int(config['price_accuracy']))), + 'company_id': fields.related('account_id','company_id',type='many2one',relation='res.company',string='Company'), } def base_change(self, cr, uid, ids, base,currency_id=False,company_id=False,date_invoice=False): diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 4541d3716e2..65639258381 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -657,6 +657,7 @@ class mrp_production(osv.osv): 'state': 'auto', 'address_id': address_id, 'auto_picking': self._get_auto_picking(cr, uid, production), + 'company_id': production.company_id.id, }) source = production.product_id.product_tmpl_id.property_stock_production.id @@ -671,7 +672,8 @@ class mrp_production(osv.osv): 'location_id': source, 'location_dest_id': production.location_dest_id.id, 'move_dest_id': production.move_prod_id.id, - 'state': 'waiting' + 'state': 'waiting', + 'company_id': production.company_id.id, } res_final_id = self.pool.get('stock.move').create(cr, uid, data) @@ -693,6 +695,7 @@ class mrp_production(osv.osv): 'location_dest_id': source, 'move_dest_id': res_final_id, 'state': 'waiting', + 'company_id': production.company_id.id, }) moves.append(res_dest_id) move_id = self.pool.get('stock.move').create(cr, uid, { @@ -708,6 +711,7 @@ class mrp_production(osv.osv): 'location_id': production.location_src_id.id, 'location_dest_id': routing_loc or production.location_src_id.id, 'state': 'waiting', + 'company_id': production.company_id.id, }) proc_id = self.pool.get('mrp.procurement').create(cr, uid, { 'name': (production.origin or '').split(':')[0] + ':' + production.name, @@ -721,6 +725,7 @@ class mrp_production(osv.osv): 'location_id': production.location_src_id.id, 'procure_method': line.product_id.procure_method, 'move_id': move_id, + 'company_id': production.company_id.id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr) @@ -1007,6 +1012,7 @@ class mrp_procurement(osv.osv): 'product_uom': procurement.product_uom.id, 'date_planned': procurement.date_planned, 'state':'confirmed', + 'company_id': procurement.company_id.id, }) self.write(cr, uid, [procurement.id], {'move_id': id, 'close_move':1}) else: @@ -1059,6 +1065,7 @@ class mrp_procurement(osv.osv): 'bom_id': procurement.bom_id and procurement.bom_id.id or False, 'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'), 'move_prod_id': res_id, + 'company_id': procurement.company_id.id, }) self.write(cr, uid, [procurement.id], {'state':'running'}) bom_result = self.pool.get('mrp.production').action_compute(cr, uid, @@ -1258,6 +1265,7 @@ class StockMove(osv.osv): if move.state=='assigned': state='assigned' for line in res[0]: + print 'Line :',line valdef = { 'picking_id': move.picking_id.id, 'product_id': line['product_id'], @@ -1271,7 +1279,7 @@ class StockMove(osv.osv): 'location_dest_id': dest, 'move_history_ids': [(6,0,[move.id])], 'move_history_ids2': [(6,0,[])], - 'procurements': [] + 'procurements': [], } mid = self.pool.get('stock.move').copy(cr, uid, move.id, default=valdef) prodobj = self.pool.get('product.product').browse(cr, uid, line['product_id'], context=context) @@ -1287,6 +1295,7 @@ class StockMove(osv.osv): 'location_id': move.location_id.id, 'procure_method': prodobj.procure_method, 'move_id': mid, + 'company_id': line['company_id'], }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr) diff --git a/addons/multi_company/multi_company.py b/addons/multi_company/multi_company.py index 1b086b1337c..a55e28f51a2 100644 --- a/addons/multi_company/multi_company.py +++ b/addons/multi_company/multi_company.py @@ -48,9 +48,9 @@ class res_company(osv.osv): def _company_default_get(self, cr, uid, object=False, context={}): proxy = self.pool.get('multi_company.default') - ids = proxy.search(cr, uid, [('object_id.name', '=', object)]) + ids = proxy.search(cr, uid, [('object_id.model', '=', object)]) for rule in proxy.browse(cr, uid, ids, context): - user = self.pool.get('res.user').browse(cr, uid, uid) + user = self.pool.get('res.users').browse(cr, uid, uid) if eval(rule.expression, {'context': context, 'user': user}): return rule.company_dest_id.id return super(res_company, self)._company_default_get(cr, uid, object, context) diff --git a/addons/multi_company/multi_company_demo.xml b/addons/multi_company/multi_company_demo.xml index a7853319237..635cb9ddb80 100644 --- a/addons/multi_company/multi_company_demo.xml +++ b/addons/multi_company/multi_company_demo.xml @@ -369,9 +369,140 @@ - + + + + + + + Product OpenERP US + + + + + True + + + + + Product OpenERP BE + + + + + True + + + + + Product OpenERP IN + + + + + True + + + + + Partner OpenERP Editor + + + + + True + + + + + Partner Odoo + + + + + True + + + diff --git a/addons/product/product.py b/addons/product/product.py index e4d65a5b146..a0cb981229c 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -239,33 +239,6 @@ class product_template(osv.osv): result[product.id] = 1 return result - def _calc_standard_price(self, cr, uid, ids, name, arg, context=None): - res = {} - company=self.pool.get('res.users').read(cr,uid,uid,['company_id'])['company_id'] - company_cost_obj=self.pool.get('company.wise.cost.price') - for product in self.browse(cr, uid, ids, context=context): - company_cost_ids=company_cost_obj.search(cr,uid,[('company_id','=',company[0]),('product_id','=',product.id)]) - if company_cost_ids: - company_cost_data=company_cost_obj.read(cr,uid,company_cost_ids,['standard_price']) - res[product.id]=company_cost_data[0]['standard_price'] - else: - res[product.id]=1.0 - - return dict([(i, res[i]) for i in ids ]) - - def _calc_list_price(self, cr, uid, ids, name, arg, context=None): - res = {} - company=self.pool.get('res.users').read(cr,uid,uid,['company_id'])['company_id'] - company_cost_obj=self.pool.get('company.wise.sale.price') - for product in self.browse(cr, uid, ids, context=context): - company_list_ids=company_cost_obj.search(cr,uid,[('company_id','=',company[0]),('product_id','=',product.id)]) - if company_list_ids: - company_list_data=company_cost_obj.read(cr,uid,company_list_ids,['list_price']) - res[product.id]=company_list_data[0]['list_price'] - else: - res[product.id]=1.0 - return dict([(i, res[i]) for i in ids ]) - _columns = { 'name': fields.char('Name', size=128, required=True, translate=True, select=True), 'product_manager': fields.many2one('res.users','Product Manager'), @@ -304,11 +277,6 @@ class product_template(osv.osv): 'loc_row': fields.char('Row', size=16), 'loc_case': fields.char('Case', size=16), 'company_id': fields.many2one('res.company', 'Company'), - 'list_price_multi': fields.function(_calc_list_price, method=True, type='float', string='Company Sale Price', help="Base price for computing the customer price. Sometimes called the catalog price."), - 'standard_price_multi': fields.function(_calc_standard_price, method=True, type='float', string='Company Cost Price', required=True, help="The cost of the product for accounting stock valuation. It can serves as a base price for supplier price."), - 'standard_price_ids' :fields.one2many('company.wise.cost.price','product_id'), - 'list_price_ids' :fields.one2many('company.wise.sale.price','product_id') - } def _get_uom_id(self, cr, uid, *args): @@ -331,7 +299,8 @@ class product_template(osv.osv): return False _defaults = { - 'company_id': lambda self, cr, uid, context: False, # Visible by all + 'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'product.template', c), +# 'company_id': lambda self, cr, uid, context: False, # Visible by all 'type': lambda *a: 'product', 'list_price': lambda *a: 1, 'cost_method': lambda *a: 'standard', @@ -375,79 +344,6 @@ class product_template(osv.osv): product_template() -class company_wise_cost_price(osv.osv): - _name="company.wise.cost.price" - _description="Company Wise Cost Price" - _columns={ - 'product_id':fields.many2one('product.template','Product Id'), - 'company_id':fields.many2one('res.company','Company'), - 'standard_price':fields.float('Cost Price', required=True, digits=(16, int(config['price_accuracy'])), help="The cost of the product for accounting stock valuation. It can serves as a base price for supplier price."), - 'currency_id':fields.many2one('res.currency','Currency',readonly=True) - } - - def company_cost_onchange(self,cr,uid,ids,company_id): - if company_id: - currency=self.pool.get('res.company').read(cr,uid,company_id,['currency_id']) - return {'value':{'currency_id':currency['currency_id'][0]}} - else: - return{'value':{'currency_id':False}} - - def create(self,cr,uid,values,context={}): - #code to make onchange_currency_id effectiv for readonly fields - if values and values.has_key('company_id') and values['company_id']: - val = self.company_cost_onchange(cr, uid, [] ,values['company_id'])['value'] - values['currency_id']=val['currency_id'] - return super(company_wise_cost_price, self).create(cr, uid, values, context=context) - - def write(self,cr,uid,ids,values,context={}): - #code to make onchange_currency_id effectiv for readonly fields - if values and values.has_key('company_id') and values['company_id']: - company_id = values['company_id'] - # this code effects when currency_id is not changed still the rate are chnged then - # - val = self.company_cost_onchange(cr, uid, ids ,company_id)['value'] - values['currency_id']=val['currency_id'] - return super(company_wise_cost_price, self).write(cr, uid, ids, values, context=context) - -company_wise_cost_price() - -class company_wise_sale_price(osv.osv): - _name="company.wise.sale.price" - _description="Company Wise Sale Price" - _columns={ - 'product_id':fields.many2one('product.template','Product Id'), - 'company_id':fields.many2one('res.company','Company'), - 'list_price':fields.float('Sale Price', required=True, digits=(16, int(config['price_accuracy'])), help="Base price for computing the customer price. Sometimes called the catalog price."), - 'currency_id':fields.many2one('res.currency','Currency',readonly=True) - } - - def company_sale_onchange(self,cr,uid,ids,company_id): - if company_id: - currency=self.pool.get('res.company').read(cr,uid,company_id,['currency_id']) - return {'value':{'currency_id':currency['currency_id'][0]}} - else: - return{'value':{'currency_id':False}} - - def create(self,cr,uid,values,context={}): - #code to make onchange_currency_id effectiv for readonly fields - if values and values.has_key('company_id') and values['company_id']: - val = self.company_sale_onchange(cr, uid, [] ,values['company_id'])['value'] - values['currency_id']=val['currency_id'] - return super(company_wise_sale_price, self).create(cr, uid, values, context=context) - - def write(self,cr,uid,ids,values,context={}): - #code to make onchange_currency_id effectiv for readonly fields - if values and values.has_key('company_id') and values['company_id']: - company_id = values['company_id'] - # this code effects when currency_id is not changed still the rate are chnged then - # - val = self.company_sale_onchange(cr, uid, ids ,company_id)['value'] - values['currency_id']=val['currency_id'] - - return super(company_wise_sale_price, self).write(cr, uid, ids, values, context=context) - -company_wise_sale_price() - class product_product(osv.osv): def view_header_get(self, cr, uid, view_id, view_type, context): res = super(product_product, self).view_header_get(cr, uid, view_id, view_type, context) @@ -550,6 +446,7 @@ class product_product(osv.osv): 'price_extra': fields.float('Variant Price Extra', digits=(16, int(config['price_accuracy']))), 'price_margin': fields.float('Variant Price Margin', digits=(16, int(config['price_accuracy']))), 'pricelist_id': fields.dummy(string='Pricelist',relation='product.pricelist', type='many2one'), +# 'company_id': fields.many2one('res.company', 'Company'), } def onchange_uom(self, cursor, user, ids, uom_id,uom_po_id): diff --git a/addons/product/product_view.xml b/addons/product/product_view.xml index 30499aab977..36d3e9c7779 100644 --- a/addons/product/product_view.xml +++ b/addons/product/product_view.xml @@ -138,11 +138,6 @@ - - - - - @@ -595,57 +590,6 @@ - - company.wise.cost.price.form - company.wise.cost.price - form - -
- - - - - -
- - - company.wise.cost.price.tree - company.wise.cost.price - tree - - - - - - - - - - - company.wise.sale.price.form - company.wise.sale.price - form - -
- - - - - -
- - - company.wise.sale.price.tree - company.wise.sale.price - tree - - - - - - - - diff --git a/addons/product/security/ir.model.access.csv b/addons/product/security/ir.model.access.csv index 64f48a7a708..7211dc13fbe 100644 --- a/addons/product/security/ir.model.access.csv +++ b/addons/product/security/ir.model.access.csv @@ -30,5 +30,3 @@ "access_product_pricelist_type_partner_manager","product.pricelist.type partner manager","model_product_pricelist_type","base.group_partner_manager",1,0,0,0 "access_product_pricelist_partner_manager","product.pricelist partner manager","model_product_pricelist","base.group_partner_manager",1,0,0,0 "access_ir_property_group_product_manager","ir_property group_product_manager","base.model_ir_property","product.group_product_manager",1,1,1,1 -"access_company_wise_cost_price","company_wise_cost_price Manager","model_company_wise_cost_price","product.group_product_manager",1,1,1,1 -"access_company_wise_sale_price","company_wise_sale_price Manager","model_company_wise_sale_price","product.group_product_manager",1,1,1,1 diff --git a/addons/project/project.py b/addons/project/project.py index 9b97b08c433..2f134d4192e 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -326,11 +326,11 @@ class task(osv.osv): # Override view according to the company definition # def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): - tm = self.pool.get('res.users').browse(cr, uid, uid, context).company_id.project_time_mode or False - f = self.pool.get('res.company').fields_get(cr, uid, ['project_time_mode'], context) + tm = self.pool.get('res.users').browse(cr, uid, uid, context).company_id.project_time_mode_id or False + f = self.pool.get('res.company').fields_get(cr, uid, ['project_time_mode_id'], context) word = 'Hours' if tm: - word = dict(f['project_time_mode']['selection'])[tm] + word = dict(f['project_time_mode_id']['selection'])[tm] res = super(task, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu=submenu) if (not tm) or (tm=='hours'): diff --git a/addons/project_mrp/mrp.py b/addons/project_mrp/mrp.py index 911f2e229bf..2a594ff8e28 100644 --- a/addons/project_mrp/mrp.py +++ b/addons/project_mrp/mrp.py @@ -50,7 +50,8 @@ class mrp_procurement(osv.osv): 'description': content, 'date_deadline': procurement.date_planned, 'state': 'draft', - 'partner_id': l and l.order_id.partner_id.id or False + 'partner_id': l and l.order_id.partner_id.id or False, + 'company_id': procurement.company_id.id, }) return task_id mrp_procurement() diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index a3320f93977..e9b5c406af4 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -206,7 +206,7 @@ class purchase_order(osv.osv): 'invoiced': lambda *a: 0, 'partner_address_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').address_get(cr, uid, [context['partner_id']], ['default'])['default'], 'pricelist_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').browse(cr, uid, context['partner_id']).property_product_pricelist_purchase.id, - 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'purchase.order', c) + 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'purchase.order', c), } _name = "purchase.order" _description = "Purchase order" @@ -333,7 +333,8 @@ class purchase_order(osv.osv): 'origin': o.name, 'invoice_line': il, 'fiscal_position': o.partner_id.property_account_position.id, - 'payment_term':o.partner_id.property_payment_term and o.partner_id.property_payment_term.id or False, + 'payment_term': o.partner_id.property_payment_term and o.partner_id.property_payment_term.id or False, + 'company_id': o.company_id.id, } inv_id = self.pool.get('account.invoice').create(cr, uid, inv, {'type':'in_invoice'}) self.pool.get('account.invoice').button_compute(cr, uid, [inv_id], {'type':'in_invoice'}, set_total=True) @@ -385,6 +386,7 @@ class purchase_order(osv.osv): 'address_id': order.dest_address_id.id or order.partner_address_id.id, 'invoice_state': istate, 'purchase_id': order.id, + 'company_id': order.company_id.id, }) for order_line in order.order_line: if not order_line.product_id: @@ -405,12 +407,14 @@ class purchase_order(osv.osv): 'move_dest_id': order_line.move_dest_id.id, 'state': 'assigned', 'purchase_line_id': order_line.id, + 'company_id': order.company_id.id, }) if order_line.move_dest_id: self.pool.get('stock.move').write(cr, uid, [order_line.move_dest_id.id], {'location_id':order.location_id.id}) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) return picking_id + def copy(self, cr, uid, id, default=None,context={}): if not default: default = {} diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 0e4c3202e48..3e3b19b3167 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -380,7 +380,8 @@ class sale_order(osv.osv): 'comment': order.note, 'payment_term': pay_term, 'fiscal_position': order.partner_id.property_account_position.id, - 'date_invoice' : context.get('date_invoice',False) + 'date_invoice' : context.get('date_invoice',False), + 'company_id' : order.company_id.id, } inv_obj = self.pool.get('account.invoice') inv.update(self._inv_get(cr, uid, order)) @@ -578,7 +579,7 @@ class sale_order(osv.osv): 'address_id': order.partner_shipping_id.id, 'note': order.note, 'invoice_state': (order.order_policy=='picking' and '2binvoiced') or 'none', - + 'company_id': order.company_id.id, }) move_id = self.pool.get('stock.move').create(cr, uid, { @@ -600,6 +601,7 @@ class sale_order(osv.osv): 'state': 'draft', #'state': 'waiting', 'note': line.notes, + 'company_id': order.company_id.id, }) proc_id = self.pool.get('mrp.procurement').create(cr, uid, { 'name': order.name, @@ -616,6 +618,7 @@ class sale_order(osv.osv): 'procure_method': line.type, 'move_id': move_id, 'property_ids': [(6, 0, [x.id for x in line.property_ids])], + 'company_id': order.company_id.id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr) @@ -631,6 +634,7 @@ class sale_order(osv.osv): 'location_id': order.shop_id.warehouse_id.lot_stock_id.id, 'procure_method': line.type, 'property_ids': [(6, 0, [x.id for x in line.property_ids])], + 'company_id': order.company_id.id, }) self.pool.get('sale.order.line').write(cr, uid, [line.id], {'procurement_id': proc_id}) wf_service = netsvc.LocalService("workflow") @@ -768,7 +772,7 @@ class sale_order_line(osv.osv): 'state': fields.selection([('draft', 'Draft'), ('confirmed', 'Confirmed'), ('done', 'Done'), ('cancel', 'Cancelled'), ('exception', 'Exception')], 'State', required=True, readonly=True), 'order_partner_id': fields.related('order_id', 'partner_id', type='many2one', relation='res.partner', string='Customer'), 'salesman_id':fields.related('order_id','user_id',type='many2one',relation='res.users',string='Salesman'), - 'company_id': fields.related('order_id','company_id',type='many2one',relation='res.company',string='Company') + 'company_id': fields.related('order_id','company_id',type='many2one',relation='res.company',string='Company'), } _order = 'sequence, id' _defaults = { diff --git a/addons/stock/stock.py b/addons/stock/stock.py index e5e8da59493..7d924411b49 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -732,7 +732,8 @@ class stock_picking(osv.osv): 'comment': comment, 'payment_term': payment_term_id, 'fiscal_position': partner.property_account_position.id, - 'date_invoice':context.get('date_inv',False) + 'date_invoice': context.get('date_inv',False), + 'company_id': picking.company_id.id, } cur_id = self.get_currency_id(cursor, user, picking) if cur_id: @@ -889,6 +890,7 @@ class stock_production_lot(osv.osv): 'date': fields.datetime('Created Date', required=True), 'stock_available': fields.function(_get_stock, fnct_search=_stock_search, method=True, type="float", string="Available", select="2"), 'revisions': fields.one2many('stock.production.lot.revision', 'lot_id', 'Revisions'), + 'company_id': fields.many2one('res.company','Company'), } _defaults = { 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'), @@ -912,6 +914,7 @@ class stock_production_lot_revision(osv.osv): 'indice': fields.char('Revision', size=16), 'author_id': fields.many2one('res.users', 'Author'), 'lot_id': fields.many2one('stock.production.lot', 'Production lot', select=True, ondelete='cascade'), + 'company_id': fields.related('lot_id','company_id',type='many2one',relation='res.company',string='Company'), } _defaults = {