[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
This commit is contained in:
fabian 2009-12-01 15:54:18 +01:00
parent bc51ec30b3
commit 9cc171f3ef
14 changed files with 177 additions and 182 deletions

View File

@ -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: '/',

View File

@ -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')
}

View File

@ -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):

View File

@ -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)

View File

@ -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)

View File

@ -369,9 +369,140 @@
<record id="base.res_partner_accent" model="res.partner">
<field name="company_id" ref="res_company_oerp_be"/>
</record>
<!-- CRM -->
<!--
<record id="crm_configuration.crm_case_claim01" model="crm.case">
<field name="company_id" ref="res_company_oerp_be"/>
</record>
<record id="crm_configuration.crm_case_claim02" model="crm.case">
<field name="company_id" ref="res_company_oerp_us"/>
</record>
<record id="crm_configuration.crm_case_claim03" model="crm.case">
<field name="company_id" ref="res_company_oerp_be"/>
</record>
<record id="crm_configuration.crm_case_claim04" model="crm.case">
<field name="company_id" ref="res_company_oerp_in"/>
</record>
<record id="crm_configuration.crm_case_claim05" model="crm.case">
<field name="company_id" ref="res_company_oerp_be"/>
</record>
<record id="crm_configuration.crm_case_claim06" model="crm.case">
<field name="company_id" ref="res_company_oerp_us"/>
</record>
<record id="crm_configuration.crm_case_construstazunits0" model="crm.case">
<field name="company_id" ref="res_company_oerp_be"/>
</record>
<record id="crm_configuration.crm_case_rdroundfundingunits0" model="crm.case">
<field name="company_id" ref="res_company_oerp_be"/>
</record>
<record id="crm_configuration.crm_case_mediapoleunits0" model="crm.case">
<field name="company_id" ref="res_company_oerp_us"/>
</record>
<record id="crm_configuration.crm_case_abcfuelcounits0" model="crm.case">
<field name="company_id" ref="res_company_oerp_in"/>
</record>
<record id="crm_configuration.crm_case_dirtminingltdunits0" model="crm.case">
<field name="company_id" ref="res_company_oerp_us"/>
</record>
-->
<!--For Bug Tracking-->
<!--
<record id="crm_configuration.crm_case_buginaccountsmodule0" model="crm.case">
<field name="company_id" ref="res_company_oerp_be"/>
</record>
<record id="crm_configuration.crm_case_programnotgivingproperoutput0" model="crm.case">
<field name="company_id" ref="res_company_oerp_us"/>
</record>
<record id="crm_configuration.crm_case_outputincorrect0" model="crm.case">
<field name="company_id" ref="res_company_oerp_us"/>
</record>
<record id="crm_configuration.crm_case_problemloadingpage0" model="crm.case">
<field name="company_id" ref="res_company_oerp_be"/>
</record>
<record id="crm_configuration.crm_case_pagenotfound0" model="crm.case">
<field name="company_id" ref="res_company_oerp_in"/>
</record>
<record id="crm_configuration.crm_case_programmingerror0" model="crm.case">
<field name="company_id" ref="res_company_oerp_be"/>
</record>
<record id="crm_configuration.crm_case_logicalerrorinprogram0" model="crm.case">
<field name="company_id" ref="res_company_oerp_be"/>
</record>
<record id="crm_configuration.crm_case_constrainterror0" model="crm.case">
<field name="company_id" ref="res_company_oerp_us"/>
</record>
<record id="crm_configuration.crm_case_errorinprogram0" model="crm.case">
<field name="company_id" ref="res_company_oerp_be"/>
</record>
<record id="crm_configuration.crm_case_newfeaturestobeadded0" model="crm.case">
<field name="company_id" ref="res_company_oerp_be"/>
</record>
<record id="crm_configuration.crm_case_addmenustothemodule0" model="crm.case">
<field name="company_id" ref="res_company_oerp_be"/>
</record>
<record id="crm_configuration.crm_case_includeattendancesheetinproject0" model="crm.case">
<field name="company_id" ref="res_company_oerp_be"/>
</record>
<record id="crm_configuration.crm_case_createnewobject0" model="crm.case">
<field name="company_id" ref="res_company_oerp_be"/>
</record>
<record id="crm_configuration.crm_case_improvereportsinhrms0" model="crm.case">
<field name="company_id" ref="res_company_oerp_in"/>
</record>
-->
</data>
<data noupdate="1">
<record id="multi_company_default_productopenerpus0" model="multi_company.default">
<field name="name">Product OpenERP US</field>
<field eval="1" name="sequence"/>
<field name="company_id" ref="multi_company.res_company_oerp_us"/>
<field name="object_id" ref="product.model_product_template"/>
<field name="company_dest_id" ref="multi_company.res_company_oerp_editor"/>
<field name="expression">True</field>
</record>
</data>
<data noupdate="1">
<record id="multi_company_default_productopenerpbe0" model="multi_company.default">
<field name="name">Product OpenERP BE</field>
<field eval="1" name="sequence"/>
<field name="company_id" ref="multi_company.res_company_oerp_be"/>
<field name="object_id" ref="product.model_product_template"/>
<field name="company_dest_id" ref="multi_company.res_company_oerp_editor"/>
<field name="expression">True</field>
</record>
</data>
<data noupdate="1">
<record id="multi_company_default_productopenerpin0" model="multi_company.default">
<field name="name">Product OpenERP IN</field>
<field eval="1" name="sequence"/>
<field name="company_id" ref="multi_company.res_company_oerp_in"/>
<field name="object_id" ref="product.model_product_template"/>
<field name="company_dest_id" ref="multi_company.res_company_oerp_editor"/>
<field name="expression">True</field>
</record>
</data>
<data noupdate="1">
<record id="multi_company_default_partneropenerpeditor0" model="multi_company.default">
<field name="name">Partner OpenERP Editor</field>
<field eval="1" name="sequence"/>
<field name="company_id" ref="multi_company.res_company_oerp_editor"/>
<field name="object_id" ref="base.model_res_partner"/>
<field name="company_dest_id" ref="base.main_company"/>
<field name="expression">True</field>
</record>
</data>
<data noupdate="1">
<record id="multi_company_default_partnerodoo0" model="multi_company.default">
<field name="name">Partner Odoo</field>
<field eval="1" name="sequence"/>
<field name="company_id" ref="multi_company.res_company_odoo"/>
<field name="object_id" ref="base.model_res_partner"/>
<field name="company_dest_id" ref="base.main_company"/>
<field name="expression">True</field>
</record>
</data>
</openerp>

View File

@ -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):

View File

@ -138,11 +138,6 @@
<separator string="Base Prices" colspan="4"/>
<field name="standard_price" attrs="{'readonly':[('cost_method','=','average')]}"/>
<field name="list_price"/>
<field name="standard_price_multi"/>
<field name="list_price_multi"/>
<newline/>
<field name="standard_price_ids" nolabel="1" colspan="2"/>
<field name="list_price_ids" nolabel="1" colspan="2"/>
<newline/>
<field name="price_margin" select="1"/>
<field name="price_extra" select="1"/>
@ -595,57 +590,6 @@
<menuitem action="product_template_action_tree" id="menu_templates" parent="product.menu_main_product" sequence="2"
groups="product.group_product_variant" />
<record id="company_wise_cost_price_form_view" model="ir.ui.view">
<field name="name">company.wise.cost.price.form</field>
<field name="model">company.wise.cost.price</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Company Wise Cost Prices">
<field name="company_id" on_change="company_cost_onchange(company_id)" groups="base.group_multi_company"/>
<field name="standard_price"/>
<field name="currency_id"/>
</form>
</field>
</record>
<record id="company_wise_cost_price_tree_view" model="ir.ui.view">
<field name="name">company.wise.cost.price.tree</field>
<field name="model">company.wise.cost.price</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Company Wise Cost Prices">
<field name="company_id" groups="base.group_multi_company"/>
<field name="standard_price"/>
<field name="currency_id"/>
</tree>
</field>
</record>
<record id="company_wise_sale_price_form_view" model="ir.ui.view">
<field name="name">company.wise.sale.price.form</field>
<field name="model">company.wise.sale.price</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Company Wise Sale Prices">
<field name="company_id" on_change="company_sale_onchange(company_id)" groups="base.group_multi_company"/>
<field name="list_price"/>
<field name="currency_id"/>
</form>
</field>
</record>
<record id="company_wise_sale_price_tree_view" model="ir.ui.view">
<field name="name">company.wise.sale.price.tree</field>
<field name="model">company.wise.sale.price</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Company Wise Sale Prices">
<field name="company_id" groups="base.group_multi_company"/>
<field name="list_price"/>
<field name="currency_id"/>
</tree>
</field>
</record>
</data>
</openerp>

View File

@ -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

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
30 access_product_pricelist_type_partner_manager product.pricelist.type partner manager model_product_pricelist_type base.group_partner_manager 1 0 0 0
31 access_product_pricelist_partner_manager product.pricelist partner manager model_product_pricelist base.group_partner_manager 1 0 0 0
32 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

View File

@ -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'):

View File

@ -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()

View File

@ -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 = {}

View File

@ -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 = {

View File

@ -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 = {