Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Generate all the objects from the templates in openerp

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 216
    Comment on it

    TO Generate all the objects from the templates in wizard follow below given point in openerp
    1-param company: It refers company the wizard is running for.
    2-param code_digits: It is a number of digits that accounts code should have in the COA
    3-param transfer_account_id: It reference to the account template that will be used as intermediary account for transfers between 2 liquidity accounts
    4-param acc_ref: It does Mapping between ids of account templates and real accounts created from them
    5-param taxes_ref: It does Mapping between ids of tax templates and real taxes created from them
    6-returns: tuple with a dictionary containing
    * the mapping between the account template ids and the ids of the real accounts that have been generated from them, as first item,
    * a similar dictionary for mapping the tax templates and taxes, as second item.
    Use this function given below .py file.

      @api.multi
        def _load_template(self, company, code_digits=None, transfer_account_id=None, account_ref=None, taxes_ref=None):
            self.ensure_one()
            if account_ref is None:
                account_ref = {}
            if taxes_ref is None:
                taxes_ref = {}
            if not code_digits:
                code_digits = self.code_digits
            if not transfer_account_id:
                transfer_account_id = self.transfer_account_id
            AccountTaxObj = self.env['account.tax']
    
            # Generate taxes from templates.
            generated_tax_res = self.tax_template_ids._generate_tax(company)
            taxes_ref.update(generated_tax_res['tax_template_to_tax'])
    
            # Generating Accounts from templates.
            account_template_ref = self.generate_account(taxes_ref, account_ref, code_digits, company)
            account_ref.update(account_template_ref)
    
            # writing account values after creation of accounts
            company.transfer_account_id = account_template_ref[transfer_account_id.id]
            for key, value in generated_tax_res['account_dict'].items():
                if value['refund_account_id'] or value['account_id']:
                    AccountTaxObj.browse(key).write({
                        'refund_account_id': account_ref.get(value['refund_account_id'], False),
                        'account_id': account_ref.get(value['account_id'], False),
                    })
    
            # Create Journals
            self.generate_journals(account_ref, company)
    
            # generate properties function
            self.generate_properties(account_ref, company)
    
            # Generate Fiscal Position , Fiscal Position Accounts and Fiscal Position Taxes from templates
            self.generate_fiscal_position(taxes_ref, account_ref, company)
    
            return account_ref, taxes_ref
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: