From c21ea1fd86ca3ca7da66d7de195c1770646d2322 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Thu, 1 Jul 2010 08:29:31 +0200 Subject: [PATCH 01/38] fi bzr revid: fp@tinyerp.com-20100701062931-1rj74kisseczbgcx --- addons/project/project_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index ad28bda6d6a..1d5ade40e69 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -431,7 +431,7 @@ - + From 0042fdf5c65a1c3e61cb2932bb4044174cebe696 Mon Sep 17 00:00:00 2001 From: "rch(OpenERP)" <> Date: Fri, 2 Jul 2010 17:56:30 +0530 Subject: [PATCH 02/38] [IMP]:purchase:improved purchase dashboard. bzr revid: apa@apa-20100702122630-vh0jz3sugn396fe8 --- addons/purchase/board_purchase_view.xml | 9 +- addons/purchase/report/purchase_report.py | 18 ++-- .../purchase/report/purchase_report_view.xml | 92 +++++++++++++++++++ 3 files changed, 105 insertions(+), 14 deletions(-) diff --git a/addons/purchase/board_purchase_view.xml b/addons/purchase/board_purchase_view.xml index b1822519cf0..10e35e0e04c 100644 --- a/addons/purchase/board_purchase_view.xml +++ b/addons/purchase/board_purchase_view.xml @@ -35,12 +35,13 @@
- - + + - - + + +
diff --git a/addons/purchase/report/purchase_report.py b/addons/purchase/report/purchase_report.py index d5688e5bd22..e85561f28b6 100644 --- a/addons/purchase/report/purchase_report.py +++ b/addons/purchase/report/purchase_report.py @@ -34,16 +34,14 @@ class purchase_report(osv.osv): 'date': fields.date('Order Date', readonly=True), 'name': fields.char('Year',size=64,required=False, readonly=True), 'day': fields.char('Day', size=128, readonly=True), - 'state': fields.selection([ - ('draft','Quotation'), - ('waiting_date','Waiting Schedule'), - ('manual','Manual in progress'), - ('progress','In progress'), - ('shipping_except','Shipping Exception'), - ('invoice_except','Invoice Exception'), - ('done','Done'), - ('cancel','Cancel') - ], 'Order State', readonly=True), + 'state': fields.selection([('draft', 'Request for Quotation'), + ('wait', 'Waiting'), + ('confirmed', 'Waiting Supplier Ack'), + ('approved', 'Approved'), + ('except_picking', 'Shipping Exception'), + ('except_invoice', 'Invoice Exception'), + ('done', 'Done'), + ('cancel', 'Cancelled')],'Order State', readonly=True), 'product_id':fields.many2one('product.product', 'Product', readonly=True), 'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', readonly=True), 'location_id': fields.many2one('stock.location', 'Destination', readonly=True), diff --git a/addons/purchase/report/purchase_report_view.xml b/addons/purchase/report/purchase_report_view.xml index 6b27a0ec6df..82478da3156 100644 --- a/addons/purchase/report/purchase_report_view.xml +++ b/addons/purchase/report/purchase_report_view.xml @@ -176,6 +176,98 @@ + + purchase.by.supplier.graph + purchase.report + tree + + + + + + + + + Purchase by supplier + purchase.report + form + tree + [('state','=','done'),('date','>',(datetime.date.today()-datetime.timedelta(days=30)).strftime('%Y-%m-%d'))] + {'group_by_no_leaf':1,'group_by':['partner_id']} + + + + total.price.by.product.by.state.graph + purchase.report + tree + + + + + + + + + + Total price by product by state + purchase.report + form + tree,graph + {'group_by_no_leaf':1,'group_by':['product_id','state']} + + + + + qty.per.product.graph + purchase.report + tree + + + + + + + + + Qty. per product + purchase.report + form + tree + [('state','=','done')] + {'group_by_no_leaf':1,'group_by':['product_id']} + + + + + qty.per.product.tree + purchase.report + tree + + + + + + + + + + Purchase order per month + purchase.report + form + tree + [('date','>',time.strftime('%Y-01-01 00:00:00')),('date','<',time.strftime('%Y-12-31 23:59:59')),('state','=','done')] + {'group_by_no_leaf':1,'group_by':['month','product_id']} + + + + + Current purchases + purchase.order + form + tree,form + [('state','in',('draft','confirmed'))] + + From 0f03d60fdf6a48b1188bbcfb17fb01c17e1c420d Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Fri, 2 Jul 2010 10:57:19 +0200 Subject: [PATCH 03/38] [FIX] marketing_campaign: auto transitions are also directly processed in manual mode bzr revid: chs@openerp.com-20100702085719-isca5a7nmwa0j31i --- addons/marketing_campaign/marketing_campaign.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/marketing_campaign/marketing_campaign.py b/addons/marketing_campaign/marketing_campaign.py index ad48622bd27..3261d58686b 100644 --- a/addons/marketing_campaign/marketing_campaign.py +++ b/addons/marketing_campaign/marketing_campaign.py @@ -587,13 +587,12 @@ class marketing_campaign_workitem(osv.osv): # test test_realtime manual normal (active) # time Y N N N # signal N N N N - # auto Y Y N Y + # auto Y Y Y Y # - run = False - if transition.trigger != 'signal' and campaign_mode != 'manual': - if transition.trigger == 'auto' or campaign_mode == 'test': - run = True + run = transition.trigger == 'auto' \ + or (transition.trigger == 'time' \ + and campaign_mode == 'test') if run: new_wi = self.browse(cr, uid, wi_id, context) self._process_one(cr, uid, new_wi, context) From ee23522ca871a4e039a2256d1b1020988d5dd159 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Fri, 2 Jul 2010 11:23:19 +0200 Subject: [PATCH 04/38] [IMP] marketing_campaign: workitems of a campaign on partners are linked to this partner bzr revid: chs@openerp.com-20100702092319-u94h7j64kdbjlwey --- addons/marketing_campaign/marketing_campaign.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/addons/marketing_campaign/marketing_campaign.py b/addons/marketing_campaign/marketing_campaign.py index 3261d58686b..241edc08627 100644 --- a/addons/marketing_campaign/marketing_campaign.py +++ b/addons/marketing_campaign/marketing_campaign.py @@ -84,12 +84,12 @@ class marketing_campaign(osv.osv): _columns = { 'name': fields.char('Name', size=64, required=True), - 'object_id': fields.many2one('ir.model', 'Object', required=True, - help="Choose the Object on which you want \ + 'object_id': fields.many2one('ir.model', 'Model', required=True, + help="Choose the model on which you want \ this campaign to be run"), 'partner_field_id': fields.many2one('ir.model.fields', 'Partner Field', domain="[('model_id', '=', object_id), ('ttype', '=', 'many2one'), ('relation', '=', 'res.partner')]", - help="The generated workitems will be linked to the partner related to the record"), + help="The generated workitems will be linked to the partner related to the record. If the record is the partner itself left this field empty."), 'mode':fields.selection([('test', 'Test Directly'), ('test_realtime', 'Test in Realtime'), ('manual', 'With Manual Confirmation'), @@ -265,10 +265,14 @@ class marketing_campaign_segment(osv.osv): 'state': 'todo', 'res_id': o_ids.id } + + partner = None if partner_field: partner = getattr(o_ids, partner_field) - if partner: - wi_vals['partner_id'] = partner.id + elif model_obj._name == 'res.partner': + partner = o_ids + if partner: + wi_vals['partner_id'] = partner.id for act_id in act_ids: wi_vals['activity_id'] = act_id From 39402113ac61b6449773007c9ffa9267132d20fb Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 2 Jul 2010 12:34:32 +0200 Subject: [PATCH 05/38] [FIX] assert is a statement, not a function bzr revid: xmo@openerp.com-20100702103432-fyrdgu8a7rl4uj4u --- addons/account/account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/account.py b/addons/account/account.py index 589730c9ca7..22c234dd0ad 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1143,7 +1143,7 @@ class account_move(osv.osv): return amount def _centralise(self, cr, uid, move, mode, context=None): - assert(mode in ('debit', 'credit'), 'Invalid Mode') #to prevent sql injection + assert mode in ('debit', 'credit'), 'Invalid Mode' #to prevent sql injection if context is None: context = {} From 0e61edf9226995003f327de8f2de88384574e5f6 Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Fri, 2 Jul 2010 16:07:15 +0530 Subject: [PATCH 06/38] [FIX]: reviwe payroll and recall lost changes during the merge bzr revid: mga@tinyerp.com-20100702103715-iew7rlke3we92ipg --- addons/hr_payroll/__openerp__.py | 2 +- addons/hr_payroll/hr_payroll.py | 610 +----------------- addons/hr_payroll/hr_payroll_view.xml | 26 +- addons/hr_payroll/hr_payroll_workflow.xml | 29 +- addons/hr_payroll_account/__openerp__.py | 1 - .../hr_payroll_account/hr_payroll_account.py | 199 +++--- .../hr_payroll_account_workflow.xml | 18 +- 7 files changed, 150 insertions(+), 735 deletions(-) diff --git a/addons/hr_payroll/__openerp__.py b/addons/hr_payroll/__openerp__.py index 5c7b1436864..e0554c1738f 100644 --- a/addons/hr_payroll/__openerp__.py +++ b/addons/hr_payroll/__openerp__.py @@ -62,4 +62,4 @@ 'active': False, } -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 2f2821afb99..c04d7eb828a 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -217,63 +217,28 @@ class payroll_register(osv.osv): slip_line_pool = self.pool.get('hr.payslip.line') wf_service = netsvc.LocalService("workflow") - vals = self.read(cr, uid, ids)[0] + vals = self.browse(cr, uid, ids)[0] emp_ids = emp_pool.search(cr, uid, []) for emp in emp_pool.browse(cr, uid, emp_ids): - old_slips = slip_pool.search(cr, uid, [('employee_id','=',emp.id), ('date','=',vals['date'])]) + old_slips = slip_pool.search(cr, uid, [('employee_id','=', emp.id), ('date','=',vals.date)]) if old_slips: slip_pool.write(cr, uid, old_slips, {'register_id':ids[0]}) for sid in old_slips: wf_service.trg_validate(uid, 'hr.payslip', sid, 'compute_sheet', cr) - continue - - sql_req= ''' - SELECT c.wage as wage, struct_id as function - FROM hr_contract c - LEFT JOIN hr_employee emp on (c.employee_id=emp.id) - LEFT JOIN hr_contract_wage_type cwt on (cwt.id = c.wage_type_id) - LEFT JOIN hr_contract_wage_type_period p on (cwt.period_id = p.id) - WHERE - (emp.id=%s) AND - (date_start <= %s) AND - (date_end IS NULL OR date_end >= %s) - LIMIT 1 - ''' - cr.execute(sql_req, (emp.id, vals['date'], vals['date'])) - contract_info = cr.dictfetchone() - - if not contract_info: - continue - - function = contract_info['struct_id'] - lines = [] - if function: - func = func_pool.read(cr, uid, function, ['line_ids']) - lines = slip_line_pool.browse(cr, uid, func['line_ids']) - - res = { - 'employee_id':emp.id, - 'basic':contract_info['wage'], - 'register_id':ids[0], - 'name':vals['name'], - 'date':vals['date'], - 'journal_id':vals['journal_id'][0], - 'bank_journal_id':vals['bank_journal_id'][0] - } - slip_id = slip_pool.create(cr, uid, res) - - old_slip_id = slip_line_pool.search(cr, uid, [('slip_id','=',slip_id)]) - slip_line_pool.unlink(cr, uid, old_slip_id) - - for line in lines: - slip_line_pool.copy(cr, uid, line.id, {'slip_id':slip_id, 'employee_id':False, 'function_id':False}, {}) - - for line in emp.line_ids: - slip_line_pool.copy(cr, uid, line.id, {'slip_id':slip_id, 'employee_id':False, 'function_id':False}, {}) - - wf_service.trg_validate(uid, 'hr.payslip', slip_id, 'compute_sheet', cr) + else: + res = { + 'employee_id':emp.id, + 'basic':0.0, + 'register_id':ids[0], + 'name':vals.name, + 'date':vals.date, + 'journal_id':vals.journal_id.id, + 'bank_journal_id':vals.bank_journal_id.id + } + slip_id = slip_pool.create(cr, uid, res) + wf_service.trg_validate(uid, 'hr.payslip', slip_id, 'compute_sheet', cr) number = self.pool.get('ir.sequence').get(cr, uid, 'salary.register') self.write(cr, uid, ids, {'state':'draft', 'number':number}) @@ -291,30 +256,17 @@ class payroll_register(osv.osv): self.write(cr, uid, ids, {'state':'hr_check'}) return True - def verify_twice_sheet(self, cr, uid, ids, context={}): - slip_pool = self.pool.get('hr.payslip') - - for id in ids: - sids = slip_pool.search(cr, uid, [('register_id','=',id), ('state','=','hr_check')]) - wf_service = netsvc.LocalService("workflow") - for sid in sids: - wf_service.trg_validate(uid, 'hr.payslip', sid, 'verify_twice_sheet', cr) - - self.write(cr, uid, ids, {'state':'accont_check'}) - return True - def final_verify_sheet(self, cr, uid, ids, context={}): slip_pool = self.pool.get('hr.payslip') advice_pool = self.pool.get('hr.payroll.advice') advice_line_pool = self.pool.get('hr.payroll.advice.line') for id in ids: - sids = slip_pool.search(cr, uid, [('register_id','=',id), ('state','=','accont_check')]) + sids = slip_pool.search(cr, uid, [('register_id','=',id), ('state','=','hr_check')]) wf_service = netsvc.LocalService("workflow") for sid in sids: wf_service.trg_validate(uid, 'hr.payslip', sid, 'final_verify_sheet', cr) - for reg in self.browse(cr, uid, ids): accs = {} for slip in reg.line_ids: @@ -538,13 +490,14 @@ class payment_category(osv.osv): ('deduction','Deduction'), ('other','Others'), ],'Type', select=True), - 'base':fields.char('Based on', size=64, required=True, readonly=False, help='This will use to computer the % fields values, in general its on basic, but You can use all heads code field in small letter as a variable name i.e. hra, ma, lta, etc...., also you can use, static varible basic'), + 'base':fields.text('Based on', required=True, readonly=False, help='This will use to computer the % fields values, in general its on basic, but You can use all heads code field in small letter as a variable name i.e. hra, ma, lta, etc...., also you can use, static varible basic'), 'condition':fields.char('Condition', size=1024, required=True, readonly=False, help='Applied this head for calculation if condition is true'), 'sequence': fields.integer('Sequence', required=True, help='Use to arrange calculation sequence'), 'note': fields.text('Description'), 'user_id':fields.char('User', size=64, required=False, readonly=False), 'state':fields.char('Label', size=64, required=False, readonly=False), 'company_id':fields.many2one('res.company', 'Company', required=False), + 'contribute_ids':fields.one2many('company.contribution', 'category_id', 'Contributions', required=False), } _defaults = { 'condition': lambda *a: 'True', @@ -786,11 +739,7 @@ class hr_payslip(osv.osv): 'other_pay': fields.function(_calculate, method=True, store=True, multi='dc', string='Others', digits=(16, 2)), 'total_pay': fields.function(_calculate, method=True, store=True, multi='dc', string='Total Payment', digits=(16, 2)), 'line_ids':fields.one2many('hr.payslip.line', 'slip_id', 'Payslip Line', required=False, readonly=True, states={'draft': [('readonly', False)]}), - 'move_ids':fields.one2many('hr.payslip.account.move', 'slip_id', 'Accounting vouchers', required=False), - 'move_line_ids':fields.many2many('account.move.line', 'payslip_lines_rel', 'slip_id', 'line_id', 'Accounting Lines', readonly=True), - 'move_payment_ids':fields.many2many('account.move.line', 'payslip_payment_rel', 'slip_id', 'payment_id', 'Payment Lines', readonly=True), 'company_id':fields.many2one('res.company', 'Company', required=False), - 'period_id': fields.many2one('account.period', 'Force Period', domain=[('state','<>','done')], help="Keep empty to use the period of the validation(Payslip) date."), 'holiday_days': fields.integer('No of Leaves', readonly=True), 'worked_days': fields.integer('Worked Day', readonly=True), 'working_days': fields.integer('Working Days', readonly=True), @@ -839,162 +788,9 @@ class hr_payslip(osv.osv): return True def cancel_sheet(self, cr, uid, ids, context={}): - move_pool = self.pool.get('account.move') - - for slip in self.browse(cr, uid, ids, context): - for line in slip.move_ids: - if slip.move_id: - if slip.move_id.state == 'posted': - move_pool.button_cancel(cr, uid [slip.move_id.id], context) - move_pool.unlink(cr, uid, [slip.move_id.id]) - self.write(cr, uid, ids, {'state':'cancel'}) return True - def process_sheet(self, cr, uid, ids, context={}): - move_pool = self.pool.get('account.move') - movel_pool = self.pool.get('account.move.line') - invoice_pool = self.pool.get('account.invoice') - - for slip in self.browse(cr,uid,ids): - line_ids = [] - partner = False - partner_id = False - exp_ids = [] - - partner = slip.employee_id.address_home_id.partner_id - partner_id = partner.id - - fiscal_year_ids = self.pool.get('account.fiscalyear').search(cr, uid, []) - if not fiscal_year_ids: - raise osv.except_osv(_('Warning !'), _('Please define fiscal year for perticular contract')) - fiscal_year_objs = self.pool.get('account.fiscalyear').read(cr, uid, fiscal_year_ids, ['date_start','date_stop']) - year_exist = False - for fiscal_year in fiscal_year_objs: - if ((fiscal_year['date_start'] <= slip.date) and (fiscal_year['date_stop'] >= slip.date)): - year_exist = True - if not year_exist: - raise osv.except_osv(_('Warning !'), _('Fiscal Year is not defined for slip date %s'%slip.date)) - search_period = self.pool.get('account.period').search(cr,uid,[('date_start','<=',slip.date),('date_stop','>=',slip.date)]) - if not search_period: - raise osv.except_osv(_('Warning !'), _('Period is not defined for slip date %s'%slip.date)) - period_id = search_period[0] - name = 'Payment of Salary to %s' % (slip.employee_id.name) - move = { - 'journal_id': slip.bank_journal_id.id, - 'period_id': period_id, - 'date': slip.date, - 'type':'bank_pay_voucher', - 'ref':slip.number, - 'narration': name - } - move_id = move_pool.create(cr, uid, move) - self.create_voucher(cr, uid, [slip.id], name, move_id) - - name = "To %s account" % (slip.employee_id.name) - ded_rec = { - 'move_id':move_id, - 'name': name, - #'partner_id': partner_id, - 'date': slip.date, - 'account_id': slip.employee_id.property_bank_account.id, - 'debit': 0.0, - 'credit' : slip.total_pay, - 'journal_id' : slip.journal_id.id, - 'period_id' :period_id, - 'ref':slip.number - } - line_ids += [movel_pool.create(cr, uid, ded_rec)] - name = "By %s account" % (slip.employee_id.property_bank_account.name) - cre_rec = { - 'move_id':move_id, - 'name': name, - 'partner_id': partner_id, - 'date': slip.date, - 'account_id': partner.property_account_payable.id, - 'debit': slip.total_pay, - 'credit' : 0.0, - 'journal_id' : slip.journal_id.id, - 'period_id' :period_id, - 'ref':slip.number - } - line_ids += [movel_pool.create(cr, uid, cre_rec)] - - other_pay = slip.other_pay - #Process all Reambuse Entries - for line in slip.line_ids: - if line.type == 'otherpay' and line.expanse_id.invoice_id: - if not line.expanse_id.invoice_id.move_id: - raise osv.except_osv(_('Warning !'), _('Please Confirm all Expanse Invoice appear for Reimbursement')) - invids = [line.expanse_id.invoice_id.id] - amount = line.total - acc_id = slip.bank_journal_id.default_credit_account_id and slip.bank_journal_id.default_credit_account_id.id - period_id = slip.period_id.id - journal_id = slip.bank_journal_id.id - name = '[%s]-%s' % (slip.number, line.name) - invoice_pool.pay_and_reconcile(cr, uid, invids, amount, acc_id, period_id, journal_id, False, period_id, False, context, name) - other_pay -= amount - #TODO: link this account entries to the Payment Lines also Expanse Entries to Account Lines - l_ids = movel_pool.search(cr, uid, [('name','=',name)]) - line_ids += l_ids - - l_ids = movel_pool.search(cr, uid, [('invoice','=',line.expanse_id.invoice_id.id)]) - exp_ids += l_ids - - #Process for Other payment if any - other_move_id = False - if slip.other_pay > 0: - narration = 'Payment of Other Payeble amounts to %s' % (slip.employee_id.name) - move = { - 'journal_id': slip.bank_journal_id.id, - 'period_id': period_id, - 'date': slip.date, - 'type':'bank_pay_voucher', - 'ref':slip.number, - 'narration': narration - } - other_move_id = move_pool.create(cr, uid, move) - self.create_voucher(cr, uid, [slip.id], narration, move_id) - - name = "To %s account" % (slip.employee_id.name) - ded_rec = { - 'move_id':other_move_id, - 'name':name, - 'date':slip.date, - 'account_id':slip.employee_id.property_bank_account.id, - 'debit': 0.0, - 'credit': other_pay, - 'journal_id':slip.journal_id.id, - 'period_id':period_id, - 'ref':slip.number - } - line_ids += [movel_pool.create(cr, uid, ded_rec)] - name = "By %s account" % (slip.employee_id.property_bank_account.name) - cre_rec = { - 'move_id':other_move_id, - 'name':name, - 'partner_id':partner_id, - 'date':slip.date, - 'account_id':partner.property_account_payable.id, - 'debit': other_pay, - 'credit':0.0, - 'journal_id':slip.journal_id.id, - 'period_id':period_id, - 'ref':slip.number - } - line_ids += [movel_pool.create(cr, uid, cre_rec)] - - rec = { - 'state':'done', - 'move_payment_ids':[(6, 0, line_ids)], - 'paid':True - } - self.write(cr, uid, [slip.id], rec) - for exp_id in exp_ids: - self.write(cr, uid, [slip.id], {'move_line_ids':[(4, exp_id)]}) - - return True - def account_check_sheet(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {'state':'accont_check'}) return True @@ -1002,365 +798,15 @@ class hr_payslip(osv.osv): def hr_check_sheet(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {'state':'hr_check'}) return True - - def verify_sheet(self, cr, uid, ids, context={}): - - move_pool = self.pool.get('account.move') - movel_pool = self.pool.get('account.move.line') - exp_pool = self.pool.get('hr.expense.expense') - - for slip in self.browse(cr,uid,ids): - total_deduct = 0.0 - - line_ids = [] - partner = False - partner_id = False - - if not slip.employee_id.address_home_id: - raise osv.except_osv(_('Integrity Error !'), _('Please defined the Employee Home Address Along with Partners !!')) - - if not slip.employee_id.address_home_id.partner_id: - raise osv.except_osv(_('Integrity Error !'), _('Please defined the Partner in Home Address !!')) - - partner = slip.employee_id.address_home_id.partner_id - partner_id = slip.employee_id.address_home_id.partner_id.id - - period_id = False - - if slip.period_id: - period_id = slip.period_id.id - else: - fiscal_year_ids = self.pool.get('account.fiscalyear').search(cr, uid, []) - if not fiscal_year_ids: - raise osv.except_osv(_('Warning !'), _('Please define fiscal year for perticular contract')) - fiscal_year_objs = self.pool.get('account.fiscalyear').read(cr, uid, fiscal_year_ids, ['date_start','date_stop']) - year_exist = False - for fiscal_year in fiscal_year_objs: - if ((fiscal_year['date_start'] <= slip.date) and (fiscal_year['date_stop'] >= slip.date)): - year_exist = True - if not year_exist: - raise osv.except_osv(_('Warning !'), _('Fiscal Year is not defined for slip date %s'%slip.date)) - search_period = self.pool.get('account.period').search(cr,uid,[('date_start','<=',slip.date),('date_stop','>=',slip.date)]) - if not search_period: - raise osv.except_osv(_('Warning !'), _('Period is not defined for slip date %s'%slip.date)) - period_id = search_period[0] - - move = { - #'name': slip.name, - 'journal_id': slip.journal_id.id, - 'period_id': period_id, - 'date': slip.date, - 'ref':slip.number, - 'narration': slip.name - } - move_id = move_pool.create(cr, uid, move) - self.create_voucher(cr, uid, [slip.id], slip.name, move_id) - - line = { - 'move_id':move_id, - 'name': "By Basic Salary / " + slip.employee_id.name, - 'date': slip.date, - 'account_id': slip.employee_id.salary_account.id, - 'debit': slip.basic, - 'credit': 0.0, - 'quantity':slip.working_days, - 'journal_id': slip.journal_id.id, - 'period_id': period_id, - 'analytic_account_id': False, - 'ref':slip.number - } - - #Setting Analysis Account for Basic Salary - if slip.employee_id.analytic_account: - line['analytic_account_id'] = slip.employee_id.analytic_account.id - - move_line_id = movel_pool.create(cr, uid, line) - line_ids += [move_line_id] - - line = { - 'move_id':move_id, - 'name': "To Basic Paysble Salary / " + slip.employee_id.name, - 'partner_id': partner_id, - 'date': slip.date, - 'account_id': slip.employee_id.employee_account.id, - 'debit': 0.0, - 'quantity':slip.working_days, - 'credit': slip.basic, - 'journal_id': slip.journal_id.id, - 'period_id': period_id, - 'ref':slip.number - } - line_ids += [movel_pool.create(cr, uid, line)] - - for line in slip.line_ids: - name = "[%s] - %s / %s" % (line.code, line.name, slip.employee_id.name) - amount = line.total - - if line.type == 'leaves': - continue - - rec = { - 'move_id':move_id, - 'name': name, - 'date': slip.date, - 'account_id': line.account_id.id, - 'debit': 0.0, - 'credit' : 0.0, - 'journal_id' : slip.journal_id.id, - 'period_id' :period_id, - 'analytic_account_id':False, - 'ref':slip.number, - 'quantity':1 - } - - #Setting Analysis Account for Salary Slip Lines - if line.analytic_account_id: - rec['analytic_account_id'] = line.analytic_account_id.id - else: - rec['analytic_account_id'] = slip.deg_id.account_id.id - - if line.type == 'allounce' or line.type == 'otherpay': - rec['debit'] = amount - if not partner.property_account_payable: - raise osv.except_osv(_('Integrity Error !'), _('Please Configure Partners Payable Account!!')) - ded_rec = { - 'move_id':move_id, - 'name': name, - 'partner_id': partner_id, - 'date': slip.date, - 'account_id': partner.property_account_payable.id, - 'debit': 0.0, - 'quantity':1, - 'credit' : amount, - 'journal_id' : slip.journal_id.id, - 'period_id' :period_id, - 'ref':slip.number - } - line_ids += [movel_pool.create(cr, uid, ded_rec)] - elif line.type == 'deduction' or line.type == 'otherdeduct': - if not partner.property_account_receivable: - raise osv.except_osv(_('Integrity Error !'), _('Please Configure Partners Receivable Account!!')) - rec['credit'] = amount - total_deduct += amount - ded_rec = { - 'move_id':move_id, - 'name': name, - 'partner_id': partner_id, - 'date': slip.date, - 'quantity':1, - 'account_id': partner.property_account_receivable.id, - 'debit': amount, - 'credit' : 0.0, - 'journal_id' : slip.journal_id.id, - 'period_id' :period_id, - 'ref':slip.number - } - line_ids += [movel_pool.create(cr, uid, ded_rec)] - - line_ids += [movel_pool.create(cr, uid, rec)] - - if line.company_contrib > 0: - company_contrib = line.company_contrib -# if line.category_id.amount_type == 'per': -# company_contrib = (amount * line.category_id.contribute_per) - - narration = """Company Contribution of %s Encode same as a Company Expanse @ %s""" % (line.name, company_contrib) - move = { - #'name': slip.name, - 'journal_id': slip.journal_id.id, - 'period_id': period_id, - 'date': slip.date, - 'ref':slip.number, - 'narration': narration - } - company_contrib_move_id = move_pool.create(cr, uid, move) - name = "[%s] - %s / %s - Company Contribution" % (line.code, line.name, slip.employee_id.name) - self.create_voucher(cr, uid, [slip.id], name, company_contrib_move_id) - - ded_deb = { - 'move_id':company_contrib_move_id, - 'name': name, - 'date': slip.date, - 'quantity':1, - 'account_id': line.category_id.account_id.id, - 'debit': company_contrib, - 'credit' : 0.0, - 'journal_id': slip.journal_id.id, - 'period_id': period_id, - 'ref':slip.number - } - line_ids += [movel_pool.create(cr, uid, ded_deb)] - ded_cre = { - 'move_id':company_contrib_move_id, - 'name': name, - 'date': slip.date, - 'quantity':1, - 'account_id': line.category_id.register_id.account_id.id, - 'debit': 0.0, - 'credit' : company_contrib, - 'journal_id': slip.journal_id.id, - 'period_id': period_id, - 'ref':slip.number - } - line_ids += [movel_pool.create(cr, uid, ded_cre)] - - if line.category_id.include_in_salary: - narration = """Company Contribution of %s Deducted from Employee %s""" % (line.name, company_contrib) - move = { - #'name': slip.name, - 'journal_id': slip.journal_id.id, - 'period_id': period_id, - 'date': slip.date, - 'ref':slip.number, - 'narration': narration - } - include_in_salary_move_id = move_pool.create(cr, uid, move) - self.create_voucher(cr, uid, [slip.id], narration, include_in_salary_move_id) - - total_deduct += company_contrib - ded_deb = { - 'move_id':include_in_salary_move_id, - 'name': name, - 'partner_id': partner_id, - 'date': slip.date, - 'quantity':1, - 'account_id': partner.property_account_receivable.id, - 'debit': company_contrib, - 'credit' : 0.0, - 'journal_id': slip.journal_id.id, - 'period_id': period_id, - 'ref':slip.number - } - line_ids += [movel_pool.create(cr, uid, ded_deb)] - ded_cre = { - 'move_id':include_in_salary_move_id, - 'name': name, - 'date': slip.date, - 'quantity':1, - 'account_id': line.category_id.account_id.id, - 'debit': 0.0, - 'credit' : company_contrib, - 'journal_id': slip.journal_id.id, - 'period_id': period_id, - 'ref':slip.number - } - line_ids += [movel_pool.create(cr, uid, ded_cre)] - - #make an entry line to contribution register - if line.category_id.register_id: - ctr = { - 'register_id':line.category_id.register_id.id, - 'name':line.name, - 'code':line.code, - 'employee_id':slip.employee_id.id, - 'period_id':period_id, - 'emp_deduction':amount, - } - if line.category_id.contribute: - ctr['comp_deduction'] = amount - - company = 0.0 - employee = 0.0 - if line.category_id.contribute and line.category_id.include_in_salary and line.category_id.amount_type == 'per': - new_amount = (amount * (line.category_id.contribute_per / (1+line.category_id.contribute_per))) - company = new_amount - employee = amount - company - - elif line.category_id.contribute and line.category_id.include_in_salary and line.category_id.amount_type == 'fix': - company = line.category_id.contribute_per - employee = amount - company - - elif line.category_id.contribute and line.category_id.include_in_salary and line.category_id.amount_type == 'func': - company = self.pool.get('hr.allounce.deduction.categoty').execute_function(cr, uid, line.category_id.id, line.slip_id.basic, context) - employee = amount - - elif line.category_id.contribute and not line.category_id.include_in_salary and line.category_id.amount_type == 'per': - company = amount * line.category_id.contribute_per - employee = amount - - elif line.category_id.contribute and not line.category_id.include_in_salary and line.category_id.amount_type == 'fix': - company = line.category_id.contribute_per - employee = amount - - elif line.category_id.contribute and not line.category_id.include_in_salary and line.category_id.amount_type == 'func': - company = self.pool.get('hr.allounce.deduction.categoty').execute_function(cr, uid, line.category_id.id, line.slip_id.basic, context) - employee = amount - - ctr['emp_deduction'] = employee - ctr['comp_deduction'] = company - - self.pool.get('hr.contibution.register.line').create(cr, uid, ctr) - - adj_move_id = False - if total_deduct > 0: - move = { - 'journal_id': slip.journal_id.id, - 'period_id': period_id, - 'date': slip.date, - 'ref':slip.number, - 'narration': 'Adjustment : %s' % (slip.name) - } - adj_move_id = move_pool.create(cr, uid, move) - name = "Adjustment Entry - %s" % (slip.employee_id.name) - self.create_voucher(cr, uid, [slip.id], name, adj_move_id) - - ded_rec = { - 'move_id':adj_move_id, - 'name': name, - 'partner_id': partner_id, - 'date': slip.date, - 'account_id': partner.property_account_receivable.id, - 'debit': 0.0, - 'quantity':1, - 'credit' : total_deduct, - 'journal_id' : slip.journal_id.id, - 'period_id' :period_id, - 'ref':slip.number - } - line_ids += [movel_pool.create(cr, uid, ded_rec)] - cre_rec = { - 'move_id':adj_move_id, - 'name': name, - 'partner_id': partner_id, - 'date': slip.date, - 'account_id': partner.property_account_payable.id, - 'debit': total_deduct, - 'quantity':1, - 'credit' : 0.0, - 'journal_id' : slip.journal_id.id, - 'period_id' :period_id, - 'ref':slip.number - } - line_ids += [movel_pool.create(cr, uid, cre_rec)] - - rec = { - 'state':'confirm', - 'move_line_ids':[(6, 0,line_ids)], - } - if not slip.period_id: - rec['period_id'] = period_id - - dates = prev_bounds(slip.date) - exp_ids = exp_pool.search(cr, uid, [('date_valid','>=',dates[0]), ('date_valid','<=',dates[1]), ('state','=','invoiced')]) - if exp_ids: - acc = self.pool.get('ir.property').get(cr, uid, 'property_account_expense_categ', 'product.category') - for exp in exp_pool.browse(cr, uid, exp_ids): - exp_res = { - 'name':exp.name, - 'amount_type':'fix', - 'type':'otherpay', - 'category_id':exp.category_id.id, - 'amount':exp.amount, - 'slip_id':slip.id, - 'expanse_id':exp.id, - 'account_id':acc - } - self.pool.get('hr.payslip.line').create(cr, uid, exp_res) - - self.write(cr, uid, [slip.id], rec) - + + def process_sheet(self, cr, uid, ids, context={}): + self.write(cr, uid, ids, {'state':'done'}) return True - + + def verify_sheet(self, cr, uid, ids, context={}): + self.write(cr, uid, ids, {'state':'confirm'}) + return True + def get_contract(self, cr, uid, employee, date, context={}): sql_req= ''' SELECT c.id as id, c.wage as wage, struct_id as function @@ -1530,6 +976,7 @@ class hr_payslip(osv.osv): else: if line.amount_type in ('fix', 'per'): value = line.amount + elif line.amount_type == 'func': value = self.pool.get('hr.payslip.line').execute_function(cr, uid, line.id, amt, context) line.amount = value @@ -1549,7 +996,7 @@ class hr_payslip(osv.osv): 'base':base } slip_line_pool.copy(cr, uid, line.id, vals, {}) - + if sal_type in ('gross', 'net'): sal = contract.wage if sal_type == 'net': @@ -1830,6 +1277,7 @@ class hr_employee(osv.osv): 'hospital_id':fields.many2one('res.partner.address', 'ESI Hospital', required=False), 'passport_id':fields.many2one('hr.passport', 'Passport', required=False), 'otherid':fields.char('Other Id', size=64, required=False), + 'bank_account_id':fields.many2one('res.partner.bank', 'Bank Account', required=False, readonly=False), 'line_ids':fields.one2many('hr.payslip.line', 'employee_id', 'Salary Structure', required=False), 'slip_ids':fields.one2many('hr.payslip', 'employee_id', 'Payslips', required=False, readonly=True), 'property_bank_account': fields.property( @@ -1871,4 +1319,4 @@ class hr_employee(osv.osv): } hr_employee() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index de5c4435156..f98247236ae 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -40,7 +40,7 @@ - + hr.passport.tree hr.passport tree @@ -55,8 +55,8 @@ - - + + hr.passport.select hr.passport search @@ -159,7 +159,8 @@ - + + @@ -494,6 +495,7 @@
+ @@ -503,10 +505,9 @@