This question has been flagged
1 Reply
2180 Views

hi
could anyone explain me this below code .here what is sub and how price total compute

     

def _select(self):

select_str = """

SELECT sub.id, sub.date, sub.product_id, sub.partner_id, sub.country_id, sub.account_analytic_id,

sub.payment_term_id, sub.uom_name, sub.currency_id, sub.journal_id,

sub.fiscal_position_id, sub.user_id, sub.company_id, sub.nbr, sub.type, sub.state,

sub.categ_id, sub.date_due, sub.account_id, sub.account_line_id, sub.partner_bank_id,

sub.product_qty, sub.price_total as price_total, sub.price_average as price_average,

COALESCE(cr.rate, 1) as currency_rate, sub.residual as residual, sub.commercial_partner_id as commercial_partner_id

"""

return select_str

    
Avatar
Discard
Best Answer



    def init(self, cr):
# self._table = account_invoice_report
tools.drop_view_if_exists(cr, self._table)
cr.execute("""CREATE or REPLACE VIEW %s as (
WITH currency_rate AS (%s)
%s
FROM (
%s %s %s
) AS sub
LEFT JOIN currency_rate cr ON
(cr.currency_id = sub.currency_id AND
cr.company_id = sub.company_id AND
cr.date_start <= COALESCE(sub.date, NOW()) AND
(cr.date_end IS NULL OR cr.date_end > COALESCE(sub.date, NOW())))
)""" % (
self._table, self.pool['res.currency']._select_companies_rates(),
self._select(), self._sub_select(), self._from(), self._group_by()))

sub is the combination of sub_select,_from and _group_by

"%s %s %s"%(self._sub_select(), self._from(), self._group_by())

Hope it may help in your case

Avatar
Discard