[IMP] account: Recurring model -> convert company field to related with journal's company

[REF] Account: Periond view make company and fiscalyear widget=selection

bzr revid: mra@mra-laptop-20100923084512-vy0epr9d0fvcj0vv
This commit is contained in:
Mustufa Rangwala 2010-09-23 14:15:12 +05:30
parent 20bb9f99ef
commit 1eb80d3235
2 changed files with 12 additions and 8 deletions

View File

@ -1996,26 +1996,28 @@ class account_model(osv.osv):
_columns = {
'name': fields.char('Model Name', size=64, required=True, help="This is a model for recurring accounting entries"),
'journal_id': fields.many2one('account.journal', 'Journal', required=True),
'company_id': fields.many2one('res.company', 'Company', required=True),
'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
'lines_id': fields.one2many('account.model.line', 'model_id', 'Model Entries'),
'legend' :fields.text('Legend', readonly=True, size=100),
}
_defaults = {
'legend': lambda self, cr, uid, context:_('You can specify year, month and date in the name of the model using the following labels:\n\n%(year)s : To Specify Year \n%(month)s : To Specify Month \n%(date)s : Current Date\n\ne.g. My model on %(date)s'),
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
}
def generate(self, cr, uid, ids, datas={}, context={}):
def generate(self, cr, uid, ids, datas={}, context=None):
move_ids = []
entry = {}
account_move_obj = self.pool.get('account.move')
account_move_line_obj = self.pool.get('account.move.line')
pt_obj = self.pool.get('account.payment.term')
if datas.get('date', False):
context.update({'date':datas['date']})
period_id = self.pool.get('account.period').find(cr, uid, dt=context.get('date', False))
if context is None:
context = {}
if datas.get('date', False):
context.update({'date': datas['date']})
period_id = self.pool.get('account.period').find(cr, uid, dt=context.get('date', False))
if not period_id:
raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !'))
period_id = period_id[0]
@ -2069,7 +2071,9 @@ class account_model(osv.osv):
c = context.copy()
c.update({'journal_id': model.journal_id.id,'period_id': period_id})
account_move_line_obj.create(cr, uid, val, context=c)
return move_ids
account_model()
class account_model_line(osv.osv):

View File

@ -95,8 +95,8 @@
<field name="code"/>
<field name="date_start"/>
<field name="date_stop"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="fiscalyear_id"/>
<field name="company_id" widget="selection" groups="base.group_multi_company"/>
<field name="fiscalyear_id" widget="selection"/>
<field name="special"/>
<separator colspan="4" string="States"/>
<field name="state"/>