(self)
Create analytic items upon validation of an account.move.line having an analytic account or an analytic distribution.
Create analytic items upon validation of an account.move.line having an analytic account or an analytic distribution.
Create analytic items upon validation of an account . move . line having an analytic account or an analytic distribution .
def create_analytic_lines(self):
        """ Create analytic items upon validation of an account.move.line having an analytic account or an analytic distribution.
        """
        lines_to_create_analytic_entries = self.env['account.move.line']
        analytic_line_vals = []
        for obj_line in self:
            for tag in obj_line.analytic_tag_ids.filtered('active_analytic_distribution'):
                for distribution in tag.analytic_distribution_ids:
                    analytic_line_vals.append(obj_line._prepare_analytic_distribution_line(distribution))
            if obj_line.analytic_account_id:
                lines_to_create_analytic_entries |= obj_line

        # create analytic entries in batch
        if lines_to_create_analytic_entries:
            analytic_line_vals += lines_to_create_analytic_entries._prepare_analytic_line()

        self.env['account.analytic.line'].create(analytic_line_vals)
def create_analytic_lines ( self ) : lines_to_create_analytic_entries = self . env [ 'account.move.line' ] analytic_line_vals = [ ] for obj_line in self : for tag in obj_line . analytic_tag_ids . filtered ( 'active_analytic_distribution' ) : for distribution in tag . analytic_distribution_ids : analytic_line_vals . append ( obj_line . _prepare_analytic_distribution_line ( distribution ) ) if obj_line . analytic_account_id : lines_to_create_analytic_entries |= obj_line # create analytic entries in batch if lines_to_create_analytic_entries : analytic_line_vals += lines_to_create_analytic_entries . _prepare_analytic_line ( ) self . env [ 'account.analytic.line' ] . create ( analytic_line_vals )