bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def _check_dates(self, cr, uid, ids, context={}): task = self.read(cr, uid, ids[0],['date_start', 'date_end']) if task['date_start'] and task['date_end']: if task['date_start'] > task['date_end']: return False return True
def _check_dates(self, cr, uid, ids, context={}): task = self.read(cr, uid, ids[0],['date_start', 'date_end']) if task['date_start'] and task['date_end']: if task['date_start'] > task['date_end']: return False return True
468,000
def default_get(self, cr, uid, fields, context=None): """ This function gets default values """ if not context: context = {}
def default_get(self, cr, uid, fields, context=None): """ This function gets default values """ if not context: context = {}
468,001
def tr(src, ttype): # We try to do the same as the _(), but without the frame # inspection, since we aready are wrapping an osv function # trans_obj = self.get('ir.translation') cannot work yet :( ctx = {} if not kwargs: if args and isinstance(args[-1], dict): ctx = args[-1] else: ctx = {} elif isinstance(kwargs, dict): ctx = kwargs.get('context', {}) else: ctx = {}
def tr(src, ttype): # We try to do the same as the _(), but without the frame # inspection, since we aready are wrapping an osv function # trans_obj = self.get('ir.translation') cannot work yet :( ctx = {} if not kwargs: if args and isinstance(args[-1], dict): ctx = args[-1] elif isinstance(kwargs, dict): ctx = kwargs.get('context', {}) else: ctx = {}
468,002
def tr(src, ttype): # We try to do the same as the _(), but without the frame # inspection, since we aready are wrapping an osv function # trans_obj = self.get('ir.translation') cannot work yet :( ctx = {} if not kwargs: if args and isinstance(args[-1], dict): ctx = args[-1] else: ctx = {} elif isinstance(kwargs, dict): ctx = kwargs.get('context', {}) else: ctx = {}
def tr(src, ttype): # We try to do the same as the _(), but without the frame # inspection, since we aready are wrapping an osv function # trans_obj = self.get('ir.translation') cannot work yet :( ctx = {} if not kwargs: if args and isinstance(args[-1], dict): ctx = args[-1] elif isinstance(kwargs, dict): ctx = kwargs.get('context', {}) else: ctx = {}
468,003
def tr(src, ttype): # We try to do the same as the _(), but without the frame # inspection, since we aready are wrapping an osv function # trans_obj = self.get('ir.translation') cannot work yet :( ctx = {} if not kwargs: if args and isinstance(args[-1], dict): ctx = args[-1] else: ctx = {} elif isinstance(kwargs, dict): ctx = kwargs.get('context', {}) else: ctx = {}
def tr(src, ttype): # We try to do the same as the _(), but without the frame # inspection, since we aready are wrapping an osv function # trans_obj = self.get('ir.translation') cannot work yet :( ctx = {} if not kwargs: if args and isinstance(args[-1], dict): ctx = args[-1] else: ctx = {} elif isinstance(kwargs, dict): ctx = kwargs.get('context', {}) else: ctx = {}
468,004
def tr(src, ttype): # We try to do the same as the _(), but without the frame # inspection, since we aready are wrapping an osv function # trans_obj = self.get('ir.translation') cannot work yet :( ctx = {} if not kwargs: if args and isinstance(args[-1], dict): ctx = args[-1] else: ctx = {} elif isinstance(kwargs, dict): ctx = kwargs.get('context', {}) else: ctx = {}
deftr(src,ttype):#Wetrytodothesameasthe_(),butwithouttheframe#inspection,sinceweareadyarewrappinganosvfunction#trans_obj=self.get('ir.translation')cannotworkyet:(ctx={}ifnotkwargs:ifargsandisinstance(args[-1],dict):ctx=args[-1]else:ctx={}elifisinstance(kwargs,dict):ctx=kwargs.get('context',{})else:ctx={}
468,005
def _get_payment_term_lines(term_id, amount): term_pool = self.pool.get('account.payment.term') if term_id and amount: terms = term_pool.compute(cr, uid, term_id, amount) return terms return False
def _get_payment_term_lines(term_id, amount): term_pool = self.pool.get('account.payment.term') if term_id and amount: terms = term_pool.compute(cr, uid, term_id, amount) return terms return False
468,006
def init(self, cr): tools.drop_view_if_exists(cr, 'account_invoice_report') cr.execute(""" create or replace view account_invoice_report as ( select min(ail.id) as id, ai.date_invoice as date, to_char(ai.date_invoice, 'YYYY') as year, to_char(ai.date_invoice, 'MM') as month, to_char(ai.date_invoice, 'YYYY-MM-DD') as day, ail.product_id, ai.partner_id as partner_id, ai.payment_term as payment_term, ai.period_id as period_id, u.name as uom_name, ai.currency_id as currency_id, ai.journal_id as journal_id, ai.fiscal_position as fiscal_position, ai.user_id as user_id, ai.company_id as company_id, count(ail.*) as nbr, ai.type as type, ai.state, pt.categ_id, ai.date_due as date_due, ai.address_contact_id as address_contact_id, ai.address_invoice_id as address_invoice_id, ai.account_id as account_id, ai.partner_bank_id as partner_bank_id, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity * u.factor * -1 else ail.quantity * u.factor end) as product_qty, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity*ail.price_unit * -1 else ail.quantity*ail.price_unit end) as price_total, sum(case when ai.type in ('out_refund','in_invoice') then ai.amount_total * -1 else ai.amount_total end) as price_total_tax, (case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*ail.price_unit*-1) else sum(ail.quantity*ail.price_unit) end)/(case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*u.factor*-1) else sum(ail.quantity*u.factor) end) as price_average, sum((select extract(epoch from avg(date_trunc('day',aml.date_created)-date_trunc('day',l.create_date)))/(24*60*60)::decimal(16,2) from account_move_line as aml left join account_invoice as a ON (a.move_id=aml.move_id) left join account_invoice_line as l ON (a.id=l.invoice_id) where a.id=ai.id)) as delay_to_pay, (case when ai.type in ('out_refund','in_invoice') then ai.residual * -1 else ai.residual end)/(select count(l.*) from account_invoice_line as l left join account_invoice as a ON (a.id=l.invoice_id) where a.id=ai.id) as residual from account_invoice_line as ail left join account_invoice as ai ON (ai.id=ail.invoice_id) left join product_template pt on (pt.id=ail.product_id) left join product_uom u on (u.id=ail.uos_id) group by ail.product_id, ai.date_invoice, ai.id, to_char(ai.date_invoice, 'YYYY'), to_char(ai.date_invoice, 'MM'), to_char(ai.date_invoice, 'YYYY-MM-DD'), ai.partner_id, ai.payment_term, ai.period_id, u.name, ai.currency_id, ai.journal_id, ai.fiscal_position, ai.user_id, ai.company_id, ai.type, ai.state, pt.categ_id, ai.date_due, ai.address_contact_id, ai.address_invoice_id, ai.account_id, ai.partner_bank_id, ai.residual, ai.amount_total ) """)
def init(self, cr): tools.drop_view_if_exists(cr, 'account_invoice_report') cr.execute(""" create or replace view account_invoice_report as ( select min(ail.id) as id, ai.date_invoice as date, to_char(ai.date_invoice, 'YYYY') as year, to_char(ai.date_invoice, 'MM') as month, to_char(ai.date_invoice, 'YYYY-MM-DD') as day, ail.product_id, ai.partner_id as partner_id, ai.payment_term as payment_term, ai.period_id as period_id, u.name as uom_name, ai.currency_id as currency_id, ai.journal_id as journal_id, ai.fiscal_position as fiscal_position, ai.user_id as user_id, ai.company_id as company_id, count(ail.*) as nbr, ai.type as type, ai.state, pt.categ_id, ai.date_due as date_due, ai.address_contact_id as address_contact_id, ai.address_invoice_id as address_invoice_id, ai.account_id as account_id, ai.partner_bank_id as partner_bank_id, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity * u.factor * -1 else ail.quantity * u.factor end) as product_qty, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity*ail.price_unit * -1 else ail.quantity*ail.price_unit end) / cr.rate as price_total, sum(case when ai.type in ('out_refund','in_invoice') then ai.amount_total * -1 else ai.amount_total end) as price_total_tax, (case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*ail.price_unit*-1) else sum(ail.quantity*ail.price_unit) end)/(case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*u.factor*-1) else sum(ail.quantity*u.factor) end) as price_average, sum((select extract(epoch from avg(date_trunc('day',aml.date_created)-date_trunc('day',l.create_date)))/(24*60*60)::decimal(16,2) from account_move_line as aml left join account_invoice as a ON (a.move_id=aml.move_id) left join account_invoice_line as l ON (a.id=l.invoice_id) where a.id=ai.id)) as delay_to_pay, (case when ai.type in ('out_refund','in_invoice') then ai.residual * -1 else ai.residual end)/(select count(l.*) from account_invoice_line as l left join account_invoice as a ON (a.id=l.invoice_id) where a.id=ai.id) as residual from account_invoice_line as ail left join account_invoice as ai ON (ai.id=ail.invoice_id) left join product_template pt on (pt.id=ail.product_id) left join product_uom u on (u.id=ail.uos_id) group by ail.product_id, ai.date_invoice, ai.id, to_char(ai.date_invoice, 'YYYY'), to_char(ai.date_invoice, 'MM'), to_char(ai.date_invoice, 'YYYY-MM-DD'), ai.partner_id, ai.payment_term, ai.period_id, u.name, ai.currency_id, ai.journal_id, ai.fiscal_position, ai.user_id, ai.company_id, ai.type, ai.state, pt.categ_id, ai.date_due, ai.address_contact_id, ai.address_invoice_id, ai.account_id, ai.partner_bank_id, ai.residual, ai.amount_total ) """)
468,007
def init(self, cr): tools.drop_view_if_exists(cr, 'account_invoice_report') cr.execute(""" create or replace view account_invoice_report as ( select min(ail.id) as id, ai.date_invoice as date, to_char(ai.date_invoice, 'YYYY') as year, to_char(ai.date_invoice, 'MM') as month, to_char(ai.date_invoice, 'YYYY-MM-DD') as day, ail.product_id, ai.partner_id as partner_id, ai.payment_term as payment_term, ai.period_id as period_id, u.name as uom_name, ai.currency_id as currency_id, ai.journal_id as journal_id, ai.fiscal_position as fiscal_position, ai.user_id as user_id, ai.company_id as company_id, count(ail.*) as nbr, ai.type as type, ai.state, pt.categ_id, ai.date_due as date_due, ai.address_contact_id as address_contact_id, ai.address_invoice_id as address_invoice_id, ai.account_id as account_id, ai.partner_bank_id as partner_bank_id, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity * u.factor * -1 else ail.quantity * u.factor end) as product_qty, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity*ail.price_unit * -1 else ail.quantity*ail.price_unit end) as price_total, sum(case when ai.type in ('out_refund','in_invoice') then ai.amount_total * -1 else ai.amount_total end) as price_total_tax, (case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*ail.price_unit*-1) else sum(ail.quantity*ail.price_unit) end)/(case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*u.factor*-1) else sum(ail.quantity*u.factor) end) as price_average, sum((select extract(epoch from avg(date_trunc('day',aml.date_created)-date_trunc('day',l.create_date)))/(24*60*60)::decimal(16,2) from account_move_line as aml left join account_invoice as a ON (a.move_id=aml.move_id) left join account_invoice_line as l ON (a.id=l.invoice_id) where a.id=ai.id)) as delay_to_pay, (case when ai.type in ('out_refund','in_invoice') then ai.residual * -1 else ai.residual end)/(select count(l.*) from account_invoice_line as l left join account_invoice as a ON (a.id=l.invoice_id) where a.id=ai.id) as residual from account_invoice_line as ail left join account_invoice as ai ON (ai.id=ail.invoice_id) left join product_template pt on (pt.id=ail.product_id) left join product_uom u on (u.id=ail.uos_id) group by ail.product_id, ai.date_invoice, ai.id, to_char(ai.date_invoice, 'YYYY'), to_char(ai.date_invoice, 'MM'), to_char(ai.date_invoice, 'YYYY-MM-DD'), ai.partner_id, ai.payment_term, ai.period_id, u.name, ai.currency_id, ai.journal_id, ai.fiscal_position, ai.user_id, ai.company_id, ai.type, ai.state, pt.categ_id, ai.date_due, ai.address_contact_id, ai.address_invoice_id, ai.account_id, ai.partner_bank_id, ai.residual, ai.amount_total ) """)
def init(self, cr): tools.drop_view_if_exists(cr, 'account_invoice_report') cr.execute(""" create or replace view account_invoice_report as ( select min(ail.id) as id, ai.date_invoice as date, to_char(ai.date_invoice, 'YYYY') as year, to_char(ai.date_invoice, 'MM') as month, to_char(ai.date_invoice, 'YYYY-MM-DD') as day, ail.product_id, ai.partner_id as partner_id, ai.payment_term as payment_term, ai.period_id as period_id, u.name as uom_name, ai.currency_id as currency_id, ai.journal_id as journal_id, ai.fiscal_position as fiscal_position, ai.user_id as user_id, ai.company_id as company_id, count(ail.*) as nbr, ai.type as type, ai.state, pt.categ_id, ai.date_due as date_due, ai.address_contact_id as address_contact_id, ai.address_invoice_id as address_invoice_id, ai.account_id as account_id, ai.partner_bank_id as partner_bank_id, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity * u.factor * -1 else ail.quantity * u.factor end) as product_qty, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity*ail.price_unit * -1 else ail.quantity*ail.price_unit end) as price_total, sum(case when ai.type in ('out_refund','in_invoice') then ai.amount_total * -1 else ai.amount_total end)/(select count(l.id) from account_invoice_line as l left join account_invoice as a ON (a.id=l.invoice_id) where a.id=ai.id) /cr.rate as price_total_tax, (case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*ail.price_unit*-1) else sum(ail.quantity*ail.price_unit) end)/(case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*u.factor*-1) else sum(ail.quantity*u.factor) end) as price_average, sum((select extract(epoch from avg(date_trunc('day',aml.date_created)-date_trunc('day',l.create_date)))/(24*60*60)::decimal(16,2) from account_move_line as aml left join account_invoice as a ON (a.move_id=aml.move_id) left join account_invoice_line as l ON (a.id=l.invoice_id) where a.id=ai.id)) as delay_to_pay, (case when ai.type in ('out_refund','in_invoice') then ai.residual * -1 else ai.residual end)/(select count(l.*) from account_invoice_line as l left join account_invoice as a ON (a.id=l.invoice_id) where a.id=ai.id) as residual from account_invoice_line as ail left join account_invoice as ai ON (ai.id=ail.invoice_id) left join product_template pt on (pt.id=ail.product_id) left join product_uom u on (u.id=ail.uos_id) group by ail.product_id, ai.date_invoice, ai.id, to_char(ai.date_invoice, 'YYYY'), to_char(ai.date_invoice, 'MM'), to_char(ai.date_invoice, 'YYYY-MM-DD'), ai.partner_id, ai.payment_term, ai.period_id, u.name, ai.currency_id, ai.journal_id, ai.fiscal_position, ai.user_id, ai.company_id, ai.type, ai.state, pt.categ_id, ai.date_due, ai.address_contact_id, ai.address_invoice_id, ai.account_id, ai.partner_bank_id, ai.residual, ai.amount_total ) """)
468,008
def init(self, cr): tools.drop_view_if_exists(cr, 'account_invoice_report') cr.execute(""" create or replace view account_invoice_report as ( select min(ail.id) as id, ai.date_invoice as date, to_char(ai.date_invoice, 'YYYY') as year, to_char(ai.date_invoice, 'MM') as month, to_char(ai.date_invoice, 'YYYY-MM-DD') as day, ail.product_id, ai.partner_id as partner_id, ai.payment_term as payment_term, ai.period_id as period_id, u.name as uom_name, ai.currency_id as currency_id, ai.journal_id as journal_id, ai.fiscal_position as fiscal_position, ai.user_id as user_id, ai.company_id as company_id, count(ail.*) as nbr, ai.type as type, ai.state, pt.categ_id, ai.date_due as date_due, ai.address_contact_id as address_contact_id, ai.address_invoice_id as address_invoice_id, ai.account_id as account_id, ai.partner_bank_id as partner_bank_id, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity * u.factor * -1 else ail.quantity * u.factor end) as product_qty, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity*ail.price_unit * -1 else ail.quantity*ail.price_unit end) as price_total, sum(case when ai.type in ('out_refund','in_invoice') then ai.amount_total * -1 else ai.amount_total end) as price_total_tax, (case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*ail.price_unit*-1) else sum(ail.quantity*ail.price_unit) end)/(case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*u.factor*-1) else sum(ail.quantity*u.factor) end) as price_average, sum((select extract(epoch from avg(date_trunc('day',aml.date_created)-date_trunc('day',l.create_date)))/(24*60*60)::decimal(16,2) from account_move_line as aml left join account_invoice as a ON (a.move_id=aml.move_id) left join account_invoice_line as l ON (a.id=l.invoice_id) where a.id=ai.id)) as delay_to_pay, (case when ai.type in ('out_refund','in_invoice') then ai.residual * -1 else ai.residual end)/(select count(l.*) from account_invoice_line as l left join account_invoice as a ON (a.id=l.invoice_id) where a.id=ai.id) as residual from account_invoice_line as ail left join account_invoice as ai ON (ai.id=ail.invoice_id) left join product_template pt on (pt.id=ail.product_id) left join product_uom u on (u.id=ail.uos_id) group by ail.product_id, ai.date_invoice, ai.id, to_char(ai.date_invoice, 'YYYY'), to_char(ai.date_invoice, 'MM'), to_char(ai.date_invoice, 'YYYY-MM-DD'), ai.partner_id, ai.payment_term, ai.period_id, u.name, ai.currency_id, ai.journal_id, ai.fiscal_position, ai.user_id, ai.company_id, ai.type, ai.state, pt.categ_id, ai.date_due, ai.address_contact_id, ai.address_invoice_id, ai.account_id, ai.partner_bank_id, ai.residual, ai.amount_total ) """)
def init(self, cr): tools.drop_view_if_exists(cr, 'account_invoice_report') cr.execute(""" create or replace view account_invoice_report as ( select min(ail.id) as id, ai.date_invoice as date, to_char(ai.date_invoice, 'YYYY') as year, to_char(ai.date_invoice, 'MM') as month, to_char(ai.date_invoice, 'YYYY-MM-DD') as day, ail.product_id, ai.partner_id as partner_id, ai.payment_term as payment_term, ai.period_id as period_id, u.name as uom_name, ai.currency_id as currency_id, ai.journal_id as journal_id, ai.fiscal_position as fiscal_position, ai.user_id as user_id, ai.company_id as company_id, count(ail.*) as nbr, ai.type as type, ai.state, pt.categ_id, ai.date_due as date_due, ai.address_contact_id as address_contact_id, ai.address_invoice_id as address_invoice_id, ai.account_id as account_id, ai.partner_bank_id as partner_bank_id, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity * u.factor * -1 else ail.quantity * u.factor end) as product_qty, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity*ail.price_unit * -1 else ail.quantity*ail.price_unit end) as price_total, sum(case when ai.type in ('out_refund','in_invoice') then ai.amount_total * -1 else ai.amount_total end) as price_total_tax, (case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*ail.price_unit*-1) else sum(ail.quantity*ail.price_unit) end)/(case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*u.factor*-1) else sum(ail.quantity*u.factor) end) / cr.rate as price_average, cr.rate as currency_rate, sum((select extract(epoch from avg(date_trunc('day',aml.date_created)-date_trunc('day',l.create_date)))/(24*60*60)::decimal(16,2) from account_move_line as aml left join account_invoice as a ON (a.move_id=aml.move_id) left join account_invoice_line as l ON (a.id=l.invoice_id) where a.id=ai.id)) as delay_to_pay, (case when ai.type in ('out_refund','in_invoice') then ai.residual * -1 else ai.residual end)/(select count(l.*) from account_invoice_line as l left join account_invoice as a ON (a.id=l.invoice_id) where a.id=ai.id) as residual from account_invoice_line as ail left join account_invoice as ai ON (ai.id=ail.invoice_id) left join product_template pt on (pt.id=ail.product_id) left join product_uom u on (u.id=ail.uos_id) group by ail.product_id, ai.date_invoice, ai.id, to_char(ai.date_invoice, 'YYYY'), to_char(ai.date_invoice, 'MM'), to_char(ai.date_invoice, 'YYYY-MM-DD'), ai.partner_id, ai.payment_term, ai.period_id, u.name, ai.currency_id, ai.journal_id, ai.fiscal_position, ai.user_id, ai.company_id, ai.type, ai.state, pt.categ_id, ai.date_due, ai.address_contact_id, ai.address_invoice_id, ai.account_id, ai.partner_bank_id, ai.residual, ai.amount_total ) """)
468,009
def init(self, cr): tools.drop_view_if_exists(cr, 'account_invoice_report') cr.execute(""" create or replace view account_invoice_report as ( select min(ail.id) as id, ai.date_invoice as date, to_char(ai.date_invoice, 'YYYY') as year, to_char(ai.date_invoice, 'MM') as month, to_char(ai.date_invoice, 'YYYY-MM-DD') as day, ail.product_id, ai.partner_id as partner_id, ai.payment_term as payment_term, ai.period_id as period_id, u.name as uom_name, ai.currency_id as currency_id, ai.journal_id as journal_id, ai.fiscal_position as fiscal_position, ai.user_id as user_id, ai.company_id as company_id, count(ail.*) as nbr, ai.type as type, ai.state, pt.categ_id, ai.date_due as date_due, ai.address_contact_id as address_contact_id, ai.address_invoice_id as address_invoice_id, ai.account_id as account_id, ai.partner_bank_id as partner_bank_id, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity * u.factor * -1 else ail.quantity * u.factor end) as product_qty, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity*ail.price_unit * -1 else ail.quantity*ail.price_unit end) as price_total, sum(case when ai.type in ('out_refund','in_invoice') then ai.amount_total * -1 else ai.amount_total end) as price_total_tax, (case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*ail.price_unit*-1) else sum(ail.quantity*ail.price_unit) end)/(case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*u.factor*-1) else sum(ail.quantity*u.factor) end) as price_average, sum((select extract(epoch from avg(date_trunc('day',aml.date_created)-date_trunc('day',l.create_date)))/(24*60*60)::decimal(16,2) from account_move_line as aml left join account_invoice as a ON (a.move_id=aml.move_id) left join account_invoice_line as l ON (a.id=l.invoice_id) where a.id=ai.id)) as delay_to_pay, (case when ai.type in ('out_refund','in_invoice') then ai.residual * -1 else ai.residual end)/(select count(l.*) from account_invoice_line as l left join account_invoice as a ON (a.id=l.invoice_id) where a.id=ai.id) as residual from account_invoice_line as ail left join account_invoice as ai ON (ai.id=ail.invoice_id) left join product_template pt on (pt.id=ail.product_id) left join product_uom u on (u.id=ail.uos_id) group by ail.product_id, ai.date_invoice, ai.id, to_char(ai.date_invoice, 'YYYY'), to_char(ai.date_invoice, 'MM'), to_char(ai.date_invoice, 'YYYY-MM-DD'), ai.partner_id, ai.payment_term, ai.period_id, u.name, ai.currency_id, ai.journal_id, ai.fiscal_position, ai.user_id, ai.company_id, ai.type, ai.state, pt.categ_id, ai.date_due, ai.address_contact_id, ai.address_invoice_id, ai.account_id, ai.partner_bank_id, ai.residual, ai.amount_total ) """)
def init(self, cr): tools.drop_view_if_exists(cr, 'account_invoice_report') cr.execute(""" create or replace view account_invoice_report as ( select min(ail.id) as id, ai.date_invoice as date, to_char(ai.date_invoice, 'YYYY') as year, to_char(ai.date_invoice, 'MM') as month, to_char(ai.date_invoice, 'YYYY-MM-DD') as day, ail.product_id, ai.partner_id as partner_id, ai.payment_term as payment_term, ai.period_id as period_id, u.name as uom_name, ai.currency_id as currency_id, ai.journal_id as journal_id, ai.fiscal_position as fiscal_position, ai.user_id as user_id, ai.company_id as company_id, count(ail.*) as nbr, ai.type as type, ai.state, pt.categ_id, ai.date_due as date_due, ai.address_contact_id as address_contact_id, ai.address_invoice_id as address_invoice_id, ai.account_id as account_id, ai.partner_bank_id as partner_bank_id, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity * u.factor * -1 else ail.quantity * u.factor end) as product_qty, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity*ail.price_unit * -1 else ail.quantity*ail.price_unit end) as price_total, sum(case when ai.type in ('out_refund','in_invoice') then ai.amount_total * -1 else ai.amount_total end) as price_total_tax, (case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*ail.price_unit*-1) else sum(ail.quantity*ail.price_unit) end)/(case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*u.factor*-1) else sum(ail.quantity*u.factor) end) as price_average, sum((select extract(epoch from avg(date_trunc('day',aml.date_created)-date_trunc('day',l.create_date)))/(24*60*60)::decimal(16,2) from account_move_line as aml left join account_invoice as a ON (a.move_id=aml.move_id) left join account_invoice_line as l ON (a.id=l.invoice_id) where a.id=ai.id)) as delay_to_pay, (case when ai.type in ('out_refund','in_invoice') then ai.residual * -1 else ai.residual end)/(select count(l.id) from account_invoice_line as l left join account_invoice as a ON (a.id=l.invoice_id) where a.id=ai.id) as residual from account_invoice_line as ail left join account_invoice as ai ON (ai.id=ail.invoice_id) left join product_template pt on (pt.id=ail.product_id) left join product_uom u on (u.id=ail.uos_id) group by ail.product_id, ai.date_invoice, ai.id, to_char(ai.date_invoice, 'YYYY'), to_char(ai.date_invoice, 'MM'), to_char(ai.date_invoice, 'YYYY-MM-DD'), ai.partner_id, ai.payment_term, ai.period_id, u.name, ai.currency_id, ai.journal_id, ai.fiscal_position, ai.user_id, ai.company_id, ai.type, ai.state, pt.categ_id, ai.date_due, ai.address_contact_id, ai.address_invoice_id, ai.account_id, ai.partner_bank_id, ai.residual, ai.amount_total ) """)
468,010
def init(self, cr): tools.drop_view_if_exists(cr, 'account_invoice_report') cr.execute(""" create or replace view account_invoice_report as ( select min(ail.id) as id, ai.date_invoice as date, to_char(ai.date_invoice, 'YYYY') as year, to_char(ai.date_invoice, 'MM') as month, to_char(ai.date_invoice, 'YYYY-MM-DD') as day, ail.product_id, ai.partner_id as partner_id, ai.payment_term as payment_term, ai.period_id as period_id, u.name as uom_name, ai.currency_id as currency_id, ai.journal_id as journal_id, ai.fiscal_position as fiscal_position, ai.user_id as user_id, ai.company_id as company_id, count(ail.*) as nbr, ai.type as type, ai.state, pt.categ_id, ai.date_due as date_due, ai.address_contact_id as address_contact_id, ai.address_invoice_id as address_invoice_id, ai.account_id as account_id, ai.partner_bank_id as partner_bank_id, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity * u.factor * -1 else ail.quantity * u.factor end) as product_qty, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity*ail.price_unit * -1 else ail.quantity*ail.price_unit end) as price_total, sum(case when ai.type in ('out_refund','in_invoice') then ai.amount_total * -1 else ai.amount_total end) as price_total_tax, (case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*ail.price_unit*-1) else sum(ail.quantity*ail.price_unit) end)/(case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*u.factor*-1) else sum(ail.quantity*u.factor) end) as price_average, sum((select extract(epoch from avg(date_trunc('day',aml.date_created)-date_trunc('day',l.create_date)))/(24*60*60)::decimal(16,2) from account_move_line as aml left join account_invoice as a ON (a.move_id=aml.move_id) left join account_invoice_line as l ON (a.id=l.invoice_id) where a.id=ai.id)) as delay_to_pay, (case when ai.type in ('out_refund','in_invoice') then ai.residual * -1 else ai.residual end)/(select count(l.*) from account_invoice_line as l left join account_invoice as a ON (a.id=l.invoice_id) where a.id=ai.id) as residual from account_invoice_line as ail left join account_invoice as ai ON (ai.id=ail.invoice_id) left join product_template pt on (pt.id=ail.product_id) left join product_uom u on (u.id=ail.uos_id) group by ail.product_id, ai.date_invoice, ai.id, to_char(ai.date_invoice, 'YYYY'), to_char(ai.date_invoice, 'MM'), to_char(ai.date_invoice, 'YYYY-MM-DD'), ai.partner_id, ai.payment_term, ai.period_id, u.name, ai.currency_id, ai.journal_id, ai.fiscal_position, ai.user_id, ai.company_id, ai.type, ai.state, pt.categ_id, ai.date_due, ai.address_contact_id, ai.address_invoice_id, ai.account_id, ai.partner_bank_id, ai.residual, ai.amount_total ) """)
def init(self, cr): tools.drop_view_if_exists(cr, 'account_invoice_report') cr.execute(""" create or replace view account_invoice_report as ( select min(ail.id) as id, ai.date_invoice as date, to_char(ai.date_invoice, 'YYYY') as year, to_char(ai.date_invoice, 'MM') as month, to_char(ai.date_invoice, 'YYYY-MM-DD') as day, ail.product_id, ai.partner_id as partner_id, ai.payment_term as payment_term, ai.period_id as period_id, u.name as uom_name, ai.currency_id as currency_id, ai.journal_id as journal_id, ai.fiscal_position as fiscal_position, ai.user_id as user_id, ai.company_id as company_id, count(ail.*) as nbr, ai.type as type, ai.state, pt.categ_id, ai.date_due as date_due, ai.address_contact_id as address_contact_id, ai.address_invoice_id as address_invoice_id, ai.account_id as account_id, ai.partner_bank_id as partner_bank_id, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity * u.factor * -1 else ail.quantity * u.factor end) as product_qty, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity*ail.price_unit * -1 else ail.quantity*ail.price_unit end) as price_total, sum(case when ai.type in ('out_refund','in_invoice') then ai.amount_total * -1 else ai.amount_total end) as price_total_tax, (case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*ail.price_unit*-1) else sum(ail.quantity*ail.price_unit) end)/(case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*u.factor*-1) else sum(ail.quantity*u.factor) end) as price_average, sum((select extract(epoch from avg(date_trunc('day',aml.date_created)-date_trunc('day',l.create_date)))/(24*60*60)::decimal(16,2) from account_move_line as aml left join account_invoice as a ON (a.move_id=aml.move_id) left join account_invoice_line as l ON (a.id=l.invoice_id) where a.id=ai.id)) as delay_to_pay, (case when ai.type in ('out_refund','in_invoice') then ai.residual * -1 else ai.residual end)/(select count(l.*) from account_invoice_line as l left join account_invoice as a ON (a.id=l.invoice_id) where a.id=ai.id) / cr.rate as residual from account_invoice_line as ail left join account_invoice as ai ON (ai.id=ail.invoice_id) left join product_template pt on (pt.id=ail.product_id) left join product_uom u on (u.id=ail.uos_id) group by ail.product_id, ai.date_invoice, ai.id, to_char(ai.date_invoice, 'YYYY'), to_char(ai.date_invoice, 'MM'), to_char(ai.date_invoice, 'YYYY-MM-DD'), ai.partner_id, ai.payment_term, ai.period_id, u.name, ai.currency_id, ai.journal_id, ai.fiscal_position, ai.user_id, ai.company_id, ai.type, ai.state, pt.categ_id, ai.date_due, ai.address_contact_id, ai.address_invoice_id, ai.account_id, ai.partner_bank_id, ai.residual, ai.amount_total ) """)
468,011
def init(self, cr): tools.drop_view_if_exists(cr, 'account_invoice_report') cr.execute(""" create or replace view account_invoice_report as ( select min(ail.id) as id, ai.date_invoice as date, to_char(ai.date_invoice, 'YYYY') as year, to_char(ai.date_invoice, 'MM') as month, to_char(ai.date_invoice, 'YYYY-MM-DD') as day, ail.product_id, ai.partner_id as partner_id, ai.payment_term as payment_term, ai.period_id as period_id, u.name as uom_name, ai.currency_id as currency_id, ai.journal_id as journal_id, ai.fiscal_position as fiscal_position, ai.user_id as user_id, ai.company_id as company_id, count(ail.*) as nbr, ai.type as type, ai.state, pt.categ_id, ai.date_due as date_due, ai.address_contact_id as address_contact_id, ai.address_invoice_id as address_invoice_id, ai.account_id as account_id, ai.partner_bank_id as partner_bank_id, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity * u.factor * -1 else ail.quantity * u.factor end) as product_qty, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity*ail.price_unit * -1 else ail.quantity*ail.price_unit end) as price_total, sum(case when ai.type in ('out_refund','in_invoice') then ai.amount_total * -1 else ai.amount_total end) as price_total_tax, (case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*ail.price_unit*-1) else sum(ail.quantity*ail.price_unit) end)/(case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*u.factor*-1) else sum(ail.quantity*u.factor) end) as price_average, sum((select extract(epoch from avg(date_trunc('day',aml.date_created)-date_trunc('day',l.create_date)))/(24*60*60)::decimal(16,2) from account_move_line as aml left join account_invoice as a ON (a.move_id=aml.move_id) left join account_invoice_line as l ON (a.id=l.invoice_id) where a.id=ai.id)) as delay_to_pay, (case when ai.type in ('out_refund','in_invoice') then ai.residual * -1 else ai.residual end)/(select count(l.*) from account_invoice_line as l left join account_invoice as a ON (a.id=l.invoice_id) where a.id=ai.id) as residual from account_invoice_line as ail left join account_invoice as ai ON (ai.id=ail.invoice_id) left join product_template pt on (pt.id=ail.product_id) left join product_uom u on (u.id=ail.uos_id) group by ail.product_id, ai.date_invoice, ai.id, to_char(ai.date_invoice, 'YYYY'), to_char(ai.date_invoice, 'MM'), to_char(ai.date_invoice, 'YYYY-MM-DD'), ai.partner_id, ai.payment_term, ai.period_id, u.name, ai.currency_id, ai.journal_id, ai.fiscal_position, ai.user_id, ai.company_id, ai.type, ai.state, pt.categ_id, ai.date_due, ai.address_contact_id, ai.address_invoice_id, ai.account_id, ai.partner_bank_id, ai.residual, ai.amount_total ) """)
def init(self, cr): tools.drop_view_if_exists(cr, 'account_invoice_report') cr.execute(""" create or replace view account_invoice_report as ( select min(ail.id) as id, ai.date_invoice as date, to_char(ai.date_invoice, 'YYYY') as year, to_char(ai.date_invoice, 'MM') as month, to_char(ai.date_invoice, 'YYYY-MM-DD') as day, ail.product_id, ai.partner_id as partner_id, ai.payment_term as payment_term, ai.period_id as period_id, u.name as uom_name, ai.currency_id as currency_id, ai.journal_id as journal_id, ai.fiscal_position as fiscal_position, ai.user_id as user_id, ai.company_id as company_id, count(ail.*) as nbr, ai.type as type, ai.state, pt.categ_id, ai.date_due as date_due, ai.address_contact_id as address_contact_id, ai.address_invoice_id as address_invoice_id, ai.account_id as account_id, ai.partner_bank_id as partner_bank_id, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity * u.factor * -1 else ail.quantity * u.factor end) as product_qty, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity*ail.price_unit * -1 else ail.quantity*ail.price_unit end) as price_total, sum(case when ai.type in ('out_refund','in_invoice') then ai.amount_total * -1 else ai.amount_total end) as price_total_tax, (case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*ail.price_unit*-1) else sum(ail.quantity*ail.price_unit) end)/(case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*u.factor*-1) else sum(ail.quantity*u.factor) end) as price_average, sum((select extract(epoch from avg(date_trunc('day',aml.date_created)-date_trunc('day',l.create_date)))/(24*60*60)::decimal(16,2) from account_move_line as aml left join account_invoice as a ON (a.move_id=aml.move_id) left join account_invoice_line as l ON (a.id=l.invoice_id) where a.id=ai.id)) as delay_to_pay, (case when ai.type in ('out_refund','in_invoice') then ai.residual * -1 else ai.residual end)/(select count(l.*) from account_invoice_line as l left join account_invoice as a ON (a.id=l.invoice_id) where a.id=ai.id) as residual from account_invoice_line as ail left join account_invoice as ai ON (ai.id=ail.invoice_id) left join product_template pt on (pt.id=ail.product_id) left join product_uom u on (u.id=ail.uos_id), res_currency_rate cr where cr.id in (select id from res_currency_rate cr2 where (cr2.currency_id = ai.currency_id) and ((ai.date_invoice is not null and cr.name <= ai.date_invoice) or (ai.date_invoice is null and cr.name <= NOW())) limit 1) group by ail.product_id, ai.date_invoice, ai.id, to_char(ai.date_invoice, 'YYYY'), to_char(ai.date_invoice, 'MM'), to_char(ai.date_invoice, 'YYYY-MM-DD'), ai.partner_id, ai.payment_term, ai.period_id, u.name, ai.currency_id, ai.journal_id, ai.fiscal_position, ai.user_id, ai.company_id, ai.type, ai.state, pt.categ_id, ai.date_due, ai.address_contact_id, ai.address_invoice_id, ai.account_id, ai.partner_bank_id, ai.residual, ai.amount_total ) """)
468,012
def init(self, cr): tools.drop_view_if_exists(cr, 'account_invoice_report') cr.execute(""" create or replace view account_invoice_report as ( select min(ail.id) as id, ai.date_invoice as date, to_char(ai.date_invoice, 'YYYY') as year, to_char(ai.date_invoice, 'MM') as month, to_char(ai.date_invoice, 'YYYY-MM-DD') as day, ail.product_id, ai.partner_id as partner_id, ai.payment_term as payment_term, ai.period_id as period_id, u.name as uom_name, ai.currency_id as currency_id, ai.journal_id as journal_id, ai.fiscal_position as fiscal_position, ai.user_id as user_id, ai.company_id as company_id, count(ail.*) as nbr, ai.type as type, ai.state, pt.categ_id, ai.date_due as date_due, ai.address_contact_id as address_contact_id, ai.address_invoice_id as address_invoice_id, ai.account_id as account_id, ai.partner_bank_id as partner_bank_id, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity * u.factor * -1 else ail.quantity * u.factor end) as product_qty, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity*ail.price_unit * -1 else ail.quantity*ail.price_unit end) as price_total, sum(case when ai.type in ('out_refund','in_invoice') then ai.amount_total * -1 else ai.amount_total end) as price_total_tax, (case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*ail.price_unit*-1) else sum(ail.quantity*ail.price_unit) end)/(case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*u.factor*-1) else sum(ail.quantity*u.factor) end) as price_average, sum((select extract(epoch from avg(date_trunc('day',aml.date_created)-date_trunc('day',l.create_date)))/(24*60*60)::decimal(16,2) from account_move_line as aml left join account_invoice as a ON (a.move_id=aml.move_id) left join account_invoice_line as l ON (a.id=l.invoice_id) where a.id=ai.id)) as delay_to_pay, (case when ai.type in ('out_refund','in_invoice') then ai.residual * -1 else ai.residual end)/(select count(l.*) from account_invoice_line as l left join account_invoice as a ON (a.id=l.invoice_id) where a.id=ai.id) as residual from account_invoice_line as ail left join account_invoice as ai ON (ai.id=ail.invoice_id) left join product_template pt on (pt.id=ail.product_id) left join product_uom u on (u.id=ail.uos_id) group by ail.product_id, ai.date_invoice, ai.id, to_char(ai.date_invoice, 'YYYY'), to_char(ai.date_invoice, 'MM'), to_char(ai.date_invoice, 'YYYY-MM-DD'), ai.partner_id, ai.payment_term, ai.period_id, u.name, ai.currency_id, ai.journal_id, ai.fiscal_position, ai.user_id, ai.company_id, ai.type, ai.state, pt.categ_id, ai.date_due, ai.address_contact_id, ai.address_invoice_id, ai.account_id, ai.partner_bank_id, ai.residual, ai.amount_total ) """)
def init(self, cr): tools.drop_view_if_exists(cr, 'account_invoice_report') cr.execute(""" create or replace view account_invoice_report as ( select min(ail.id) as id, ai.date_invoice as date, to_char(ai.date_invoice, 'YYYY') as year, to_char(ai.date_invoice, 'MM') as month, to_char(ai.date_invoice, 'YYYY-MM-DD') as day, ail.product_id, ai.partner_id as partner_id, ai.payment_term as payment_term, ai.period_id as period_id, u.name as uom_name, ai.currency_id as currency_id, ai.journal_id as journal_id, ai.fiscal_position as fiscal_position, ai.user_id as user_id, ai.company_id as company_id, count(ail.*) as nbr, ai.type as type, ai.state, pt.categ_id, ai.date_due as date_due, ai.address_contact_id as address_contact_id, ai.address_invoice_id as address_invoice_id, ai.account_id as account_id, ai.partner_bank_id as partner_bank_id, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity * u.factor * -1 else ail.quantity * u.factor end) as product_qty, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity*ail.price_unit * -1 else ail.quantity*ail.price_unit end) as price_total, sum(case when ai.type in ('out_refund','in_invoice') then ai.amount_total * -1 else ai.amount_total end) as price_total_tax, (case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*ail.price_unit*-1) else sum(ail.quantity*ail.price_unit) end)/(case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*u.factor*-1) else sum(ail.quantity*u.factor) end) as price_average, sum((select extract(epoch from avg(date_trunc('day',aml.date_created)-date_trunc('day',l.create_date)))/(24*60*60)::decimal(16,2) from account_move_line as aml left join account_invoice as a ON (a.move_id=aml.move_id) left join account_invoice_line as l ON (a.id=l.invoice_id) where a.id=ai.id)) as delay_to_pay, (case when ai.type in ('out_refund','in_invoice') then ai.residual * -1 else ai.residual end)/(select count(l.*) from account_invoice_line as l left join account_invoice as a ON (a.id=l.invoice_id) where a.id=ai.id) as residual from account_invoice_line as ail left join account_invoice as ai ON (ai.id=ail.invoice_id) left join product_template pt on (pt.id=ail.product_id) left join product_uom u on (u.id=ail.uos_id) group by ail.product_id, ai.date_invoice, ai.id, to_char(ai.date_invoice, 'YYYY'), to_char(ai.date_invoice, 'MM'), to_char(ai.date_invoice, 'YYYY-MM-DD'), ai.partner_id, ai.payment_term, ai.period_id, u.name, ai.currency_id, ai.journal_id, ai.fiscal_position, ai.user_id, ai.company_id, ai.type, ai.state, pt.categ_id, ai.date_due, ai.address_contact_id, ai.address_invoice_id, ai.account_id, ai.partner_bank_id, ai.residual, ai.amount_total ) """)
468,013
def lines(self, account): """ Return all the account_move_line of account with their account code counterparts """ move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted', ''] # First compute all counterpart strings for every move_id where this account appear. # Currently, the counterpart info is used only in landscape mode sql = """ SELECT m1.move_id, array_to_string(ARRAY(SELECT DISTINCT a.code FROM account_move_line m2 LEFT JOIN account_account a ON (m2.account_id=a.id) WHERE m2.move_id = m1.move_id AND m2.account_id<>%%s), ', ') AS counterpart FROM (SELECT move_id FROM account_move_line l LEFT JOIN account_move am ON (am.id = l.move_id) WHERE am.state IN %s and %s AND l.account_id = %%s GROUP BY move_id) m1 """% (tuple(move_state), self.query) self.cr.execute(sql, (account.id, account.id)) counterpart_res = self.cr.dictfetchall() counterpart_accounts = {} for i in counterpart_res: counterpart_accounts[i['move_id']]=i['counterpart'] del counterpart_res
def lines(self, account): """ Return all the account_move_line of account with their account code counterparts """ move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted', ''] # First compute all counterpart strings for every move_id where this account appear. # Currently, the counterpart info is used only in landscape mode sql = """ SELECT m1.move_id, array_to_string(ARRAY(SELECT DISTINCT a.code FROM account_move_line m2 LEFT JOIN account_account a ON (m2.account_id=a.id) WHERE m2.move_id = m1.move_id AND m2.account_id<>%%s), ', ') AS counterpart FROM (SELECT move_id FROM account_move_line l LEFT JOIN account_move am ON (am.id = l.move_id) WHERE am.state IN %s and %s AND l.account_id = %%s GROUP BY move_id) m1 """% (tuple(move_state), self.query) self.cr.execute(sql, (account.id, account.id)) counterpart_res = self.cr.dictfetchall() counterpart_accounts = {} for i in counterpart_res: counterpart_accounts[i['move_id']] = i['counterpart'] del counterpart_res
468,014
def lines(self, account): """ Return all the account_move_line of account with their account code counterparts """ move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted', ''] # First compute all counterpart strings for every move_id where this account appear. # Currently, the counterpart info is used only in landscape mode sql = """ SELECT m1.move_id, array_to_string(ARRAY(SELECT DISTINCT a.code FROM account_move_line m2 LEFT JOIN account_account a ON (m2.account_id=a.id) WHERE m2.move_id = m1.move_id AND m2.account_id<>%%s), ', ') AS counterpart FROM (SELECT move_id FROM account_move_line l LEFT JOIN account_move am ON (am.id = l.move_id) WHERE am.state IN %s and %s AND l.account_id = %%s GROUP BY move_id) m1 """% (tuple(move_state), self.query) self.cr.execute(sql, (account.id, account.id)) counterpart_res = self.cr.dictfetchall() counterpart_accounts = {} for i in counterpart_res: counterpart_accounts[i['move_id']]=i['counterpart'] del counterpart_res
deflines(self,account):"""Returnalltheaccount_move_lineofaccountwiththeiraccountcodecounterparts"""move_state=['draft','posted']ifself.target_move=='posted':move_state=['posted','']#Firstcomputeallcounterpartstringsforeverymove_idwherethisaccountappear.#Currently,thecounterpartinfoisusedonlyinlandscapemodesql="""SELECTm1.move_id,array_to_string(ARRAY(SELECTDISTINCTa.codeFROMaccount_move_linem2LEFTJOINaccount_accountaON(m2.account_id=a.id)WHEREm2.move_id=m1.move_idANDm2.account_id<>%%s),',')AScounterpartFROM(SELECTmove_idFROMaccount_move_linelLEFTJOINaccount_moveamON(am.id=l.move_id)WHEREam.stateIN%sand%sANDl.account_id=%%sGROUPBYmove_id)m1"""%(tuple(move_state),self.query)self.cr.execute(sql,(account.id,account.id))counterpart_res=self.cr.dictfetchall()counterpart_accounts={}foriincounterpart_res:counterpart_accounts[i['move_id']]=i['counterpart']delcounterpart_res
468,015
def _get_sortby(self, data): if self.sortby == 'sort_date': return 'Date' elif self.sortby == 'sort_journal_partner': return 'Journal & Partner' return 'Date'
def _get_sortby(self, data): if self.sortby == 'sort_date': return 'Date' elif self.sortby == 'sort_journal_partner': return 'Journal & Partner' return 'Date'
468,016
def reconcile(self, cr, uid, ids, context=None): move_line_obj = self.pool.get('account.move.line') obj_model = self.pool.get('ir.model.data') if context is None: context = {} form = self.read(cr, uid, ids, [])[0] max_amount = form.get('max_amount', 0.0) power = form['power'] reconciled = unreconciled = 0 if not form['account_ids']: raise osv.except_osv(_('UserError'), _('You must select accounts to reconcile')) for account_id in form['account_ids']: if not context.get('allow_write_off', False): query = "SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \ AND state <> 'draft' GROUP BY partner_id \ HAVING ABS(SUM(debit-credit)) <> %s AND count(*)>0"%(account_id, 0.0)
def reconcile(self, cr, uid, ids, context=None): move_line_obj = self.pool.get('account.move.line') obj_model = self.pool.get('ir.model.data') if context is None: context = {} form = self.read(cr, uid, ids, [])[0] max_amount = form.get('max_amount', 0.0) power = form['power'] reconciled = unreconciled = 0 if not form['account_ids']: raise osv.except_osv(_('UserError'), _('You must select accounts to reconcile')) for account_id in form['account_ids']: if not context.get('allow_write_off', False): query = "SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \ AND state <> 'draft' GROUP BY partner_id \ HAVING ABS(SUM(debit-credit)) <> %s AND count(*)>0"%(account_id, 0.0)
468,017
fld_def = (field in self._columns) and self._columns[field] or self._inherit_fields[field][2]
fld_def = (field in self._columns) and self._columns[field] or self._inherit_fields[field][2]
468,018
def get_data(self,form): cr, uid = self.cr, self.uid db_pool = pooler.get_pool(self.cr.dbname) #Getting Profit or Loss Balance from profit and Loss report result_pl=self.obj_pl.get_data(form) self.res_pl=self.obj_pl.final_result() type_pool = db_pool.get('account.account.type') account_pool = db_pool.get('account.account') year_pool = db_pool.get('account.fiscalyear')
def get_data(self,form): cr, uid = self.cr, self.uid db_pool = pooler.get_pool(self.cr.dbname) #Getting Profit or Loss Balance from profit and Loss report result_pl=self.obj_pl.get_data(form) self.res_pl=self.obj_pl.final_result() type_pool = db_pool.get('account.account.type') account_pool = db_pool.get('account.account') year_pool = db_pool.get('account.fiscalyear')
468,019
def import_data(self, cr, uid, fields, datas, mode='init', current_module='', noupdate=False, context=None, filename=None): """ Import given data in given module
def import_data(self, cr, uid, fields, datas, mode='init', current_module='', noupdate=False, context=None, filename=None): """ Import given data in given module
468,020
def _check_recursion(self, cr, uid, ids): level = 100 while len(ids): cr.execute('select distinct parent_id from res_partner_category where id IN %s',(tuple(ids),)) ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False level -= 1 return True
def _check_recursion(self, cr, uid, ids): level = 100 while len(ids): cr.execute('select distinct parent_id from res_partner_category where id IN %s',(tuple(ids),)) ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False level -= 1 return True
468,021
def _append_node(name, text): n = etree.SubElement(config, name) n.text = text
def _append_node(name, text): n = etree.SubElement(config, name) n.text = text
468,022
def _append_node(name, text): n = etree.SubElement(config, name) n.text = text
def _append_node(name, text): n = etree.SubElement(config, name) n.text = text
468,023
def get_user_related_details(self, cr, uid, user_id): res = {} emp_obj = self.pool.get('hr.employee') emp_id = emp_obj.search(cr, uid, [('user_id', '=', user_id)]) if not emp_id: user_name = self.pool.get('res.users').read(cr, uid, [user_id], ['name'])[0]['name'] raise osv.except_osv(_('Bad Configuration !'), _('No employee defined for user "%s". You must create one.')% (user_name,)) emp = self.pool.get('hr.employee').browse(cr, uid, emp_id[0]) if not emp.product_id: raise osv.except_osv(_('Bad Configuration !'), _('No product defined on the related employee.\nFill in the timesheet tab of the employee form.'))
def get_user_related_details(self, cr, uid, user_id): res = {} emp_obj = self.pool.get('hr.employee') emp_id = emp_obj.search(cr, uid, [('user_id', '=', user_id)]) if not emp_id: user_name = self.pool.get('res.users').read(cr, uid, [user_id], ['name'])[0]['name'] raise osv.except_osv(_('Bad Configuration !'), _('No employee defined for user "%s". You must create one.')% (user_name,)) emp = self.pool.get('hr.employee').browse(cr, uid, emp_id[0]) if not emp.product_id: raise osv.except_osv(_('Bad Configuration !'), _('No product defined on the related employee.\nFill in the timesheet tab of the employee form.'))
468,024
def create(self, cr, uid, vals, *args, **kwargs): obj = self.pool.get('hr.analytic.timesheet') vals_line = {} obj_task = self.pool.get('project.task').browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] vals_line['unit_amount'] = vals['hours'] acc_id = obj_task.project_id.category_id.id vals_line['account_id'] = acc_id res = obj.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 00.0 vals_line['product_uom_id'] = result['product_uom_id'] timeline_id = obj.create(cr, uid, vals_line, {}) # Compute based on pricetype amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context) vals_line['amount'] = (-1) * vals['hours']* (unit_amount or 0.0) obj.write(cr, uid,[timeline_id], vals_line, {}) vals['hr_analytic_timesheet_id'] = timeline_id return super(project_work,self).create(cr, uid, vals, *args, **kwargs)
def create(self, cr, uid, vals, *args, **kwargs): obj_timesheet = self.pool.get('hr.analytic.timesheet') task_obj = self.pool.get('project.task') vals_line = {} obj_task = self.pool.get('project.task').browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] vals_line['unit_amount'] = vals['hours'] acc_id = obj_task.project_id.category_id.id vals_line['account_id'] = acc_id res = obj.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 00.0 vals_line['product_uom_id'] = result['product_uom_id'] timeline_id = obj.create(cr, uid, vals_line, {}) # Compute based on pricetype amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context) vals_line['amount'] = (-1) * vals['hours']* (unit_amount or 0.0) obj.write(cr, uid,[timeline_id], vals_line, {}) vals['hr_analytic_timesheet_id'] = timeline_id return super(project_work,self).create(cr, uid, vals, *args, **kwargs)
468,025
def create(self, cr, uid, vals, *args, **kwargs): obj = self.pool.get('hr.analytic.timesheet') vals_line = {} obj_task = self.pool.get('project.task').browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] vals_line['unit_amount'] = vals['hours'] acc_id = obj_task.project_id.category_id.id vals_line['account_id'] = acc_id res = obj.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 00.0 vals_line['product_uom_id'] = result['product_uom_id'] timeline_id = obj.create(cr, uid, vals_line, {}) # Compute based on pricetype amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context) vals_line['amount'] = (-1) * vals['hours']* (unit_amount or 0.0) obj.write(cr, uid,[timeline_id], vals_line, {}) vals['hr_analytic_timesheet_id'] = timeline_id return super(project_work,self).create(cr, uid, vals, *args, **kwargs)
def create(self, cr, uid, vals, *args, **kwargs): obj = self.pool.get('hr.analytic.timesheet') vals_line = {} obj_task = task_obj.browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] vals_line['unit_amount'] = vals['hours'] acc_id = obj_task.project_id.category_id.id vals_line['account_id'] = acc_id res = obj.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 00.0 vals_line['product_uom_id'] = result['product_uom_id'] timeline_id = obj.create(cr, uid, vals_line, {}) # Compute based on pricetype amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context) vals_line['amount'] = (-1) * vals['hours']* (unit_amount or 0.0) obj.write(cr, uid,[timeline_id], vals_line, {}) vals['hr_analytic_timesheet_id'] = timeline_id return super(project_work,self).create(cr, uid, vals, *args, **kwargs)
468,026
def create(self, cr, uid, vals, *args, **kwargs): obj = self.pool.get('hr.analytic.timesheet') vals_line = {} obj_task = self.pool.get('project.task').browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] vals_line['unit_amount'] = vals['hours'] acc_id = obj_task.project_id.category_id.id vals_line['account_id'] = acc_id res = obj.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 00.0 vals_line['product_uom_id'] = result['product_uom_id'] timeline_id = obj.create(cr, uid, vals_line, {}) # Compute based on pricetype amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context) vals_line['amount'] = (-1) * vals['hours']* (unit_amount or 0.0) obj.write(cr, uid,[timeline_id], vals_line, {}) vals['hr_analytic_timesheet_id'] = timeline_id return super(project_work,self).create(cr, uid, vals, *args, **kwargs)
def create(self, cr, uid, vals, *args, **kwargs): obj = self.pool.get('hr.analytic.timesheet') vals_line = {} obj_task = self.pool.get('project.task').browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] vals_line['unit_amount'] = vals['hours'] acc_id = obj_task.project_id.category_id.id vals_line['account_id'] = acc_id res = obj_timesheet.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 00.0 vals_line['product_uom_id'] = result['product_uom_id'] timeline_id = obj.create(cr, uid, vals_line, {}) # Compute based on pricetype amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context) vals_line['amount'] = (-1) * vals['hours']* (unit_amount or 0.0) obj.write(cr, uid,[timeline_id], vals_line, {}) vals['hr_analytic_timesheet_id'] = timeline_id return super(project_work,self).create(cr, uid, vals, *args, **kwargs)
468,027
def create(self, cr, uid, vals, *args, **kwargs): obj = self.pool.get('hr.analytic.timesheet') vals_line = {} obj_task = self.pool.get('project.task').browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] vals_line['unit_amount'] = vals['hours'] acc_id = obj_task.project_id.category_id.id vals_line['account_id'] = acc_id res = obj.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 00.0 vals_line['product_uom_id'] = result['product_uom_id'] timeline_id = obj.create(cr, uid, vals_line, {}) # Compute based on pricetype amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context) vals_line['amount'] = (-1) * vals['hours']* (unit_amount or 0.0) obj.write(cr, uid,[timeline_id], vals_line, {}) vals['hr_analytic_timesheet_id'] = timeline_id return super(project_work,self).create(cr, uid, vals, *args, **kwargs)
def create(self, cr, uid, vals, *args, **kwargs): obj = self.pool.get('hr.analytic.timesheet') vals_line = {} obj_task = self.pool.get('project.task').browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] vals_line['unit_amount'] = vals['hours'] acc_id = obj_task.project_id.category_id.id vals_line['account_id'] = acc_id res = obj.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 00.0 vals_line['product_uom_id'] = result['product_uom_id'] amount = vals_line['unit_amount'] prod_id = vals_line['product_id'] unit = False timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=kwargs['context']) # Compute based on pricetype amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context) vals_line['amount'] = (-1) * vals['hours']* (unit_amount or 0.0) obj.write(cr, uid,[timeline_id], vals_line, {}) vals['hr_analytic_timesheet_id'] = timeline_id return super(project_work,self).create(cr, uid, vals, *args, **kwargs)
468,028
def create(self, cr, uid, vals, *args, **kwargs): obj = self.pool.get('hr.analytic.timesheet') vals_line = {} obj_task = self.pool.get('project.task').browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] vals_line['unit_amount'] = vals['hours'] acc_id = obj_task.project_id.category_id.id vals_line['account_id'] = acc_id res = obj.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 00.0 vals_line['product_uom_id'] = result['product_uom_id'] timeline_id = obj.create(cr, uid, vals_line, {}) # Compute based on pricetype amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context) vals_line['amount'] = (-1) * vals['hours']* (unit_amount or 0.0) obj.write(cr, uid,[timeline_id], vals_line, {}) vals['hr_analytic_timesheet_id'] = timeline_id return super(project_work,self).create(cr, uid, vals, *args, **kwargs)
def create(self, cr, uid, vals, *args, **kwargs): obj = self.pool.get('hr.analytic.timesheet') vals_line = {} obj_task = self.pool.get('project.task').browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] vals_line['unit_amount'] = vals['hours'] acc_id = obj_task.project_id.category_id.id vals_line['account_id'] = acc_id res = obj.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 00.0 vals_line['product_uom_id'] = result['product_uom_id'] timeline_id = obj.create(cr, uid, vals_line, {}) # Compute based on pricetype amount_unit=obj_timesheet.on_change_unit_amount(cr, uid, timeline_id, prod_id, amount, unit, context=kwargs['context']) vals_line['amount'] = (-1) * vals['hours']* (amount_unit['value']['amount'] or 0.0) obj_timesheet.write(cr, uid,[timeline_id], vals_line, {}) vals['hr_analytic_timesheet_id'] = timeline_id return super(project_work,self).create(cr, uid, vals, *args, **kwargs)
468,029
def write(self, cr, uid, ids, vals, context=None): vals_line = {}
def write(self, cr, uid, ids, vals, context=None): vals_line = {}
468,030
def write(self, cr, uid, ids, vals, context=None): vals_line = {}
def write(self, cr, uid, ids, vals, context=None): vals_line = {}
468,031
def write(self, cr, uid, ids, vals, context=None): vals_line = {}
def write(self, cr, uid, ids, vals, context=None): vals_line = {}
468,032
def write(self, cr, uid, ids, vals, context=None): vals_line = {}
defwrite(self,cr,uid,ids,vals,context=None):vals_line={}
468,033
def write(self, cr, uid, ids, vals, context=None): vals_line = {}
def write(self, cr, uid, ids, vals, context=None): vals_line = {}
468,034
def unlink(self, cr, uid, ids, *args, **kwargs): for task_obj in self.browse(cr, uid, ids, *args, **kwargs): if task_obj.work_ids: work_ids = [x.id for x in task_obj.work_ids] self.pool.get('project.task.work').unlink(cr, uid, work_ids, *args, **kwargs) return super(task,self).unlink(cr, uid, ids, *args, **kwargs)
def unlink(self, cr, uid, ids, *args, **kwargs): for task_obj in self.browse(cr, uid, ids, *args, **kwargs): if task_obj.work_ids: work_ids = [x.id for x in task_obj.work_ids] self.pool.get('project.task.work').unlink(cr, uid, work_ids, *args, **kwargs) return super(task,self).unlink(cr, uid, ids, *args, **kwargs)
468,035
def unlink(self, cr, uid, ids, *args, **kwargs): for task_obj in self.browse(cr, uid, ids, *args, **kwargs): if task_obj.work_ids: work_ids = [x.id for x in task_obj.work_ids] self.pool.get('project.task.work').unlink(cr, uid, work_ids, *args, **kwargs) return super(task,self).unlink(cr, uid, ids, *args, **kwargs)
def unlink(self, cr, uid, ids, *args, **kwargs): for task_obj in self.browse(cr, uid, ids, *args, **kwargs): if task_obj.work_ids: work_ids = [x.id for x in task_obj.work_ids] self.pool.get('project.task.work').unlink(cr, uid, work_ids, *args, **kwargs) return super(task,self).unlink(cr, uid, ids, *args, **kwargs)
468,036
def _amount_all(self, cr, uid, ids, field_name, arg, context): res = {} for id in ids: print context dir, type = id.split(' ') att = self.pool.get('ir.attachment') fids = att.search(cr, uid, [('parent_id','child_of',[int(dir)]),('change_type_id','=',int(type))], context=context) res[id] = { 'amount_required': 0, 'amount_exist': 0, 'amount_percent': 0.0 } for f in att.browse(cr, uid, fids, context=context): res[id] = { 'amount_required': res[id]['amount_required'] + 1, 'amount_exist': res[id]['amount_exist'] + (f.state<>'draft') and 1 or 0, } if res[id]['amount_required']: res[id]['amount_percent'] = float(res[id]['amount_exist']*100) / res[id]['amount_required'] return res
def _amount_all(self, cr, uid, ids, field_name, arg, context): res = {} for id in ids: print context dir, type = id.split(' ') att = self.pool.get('ir.attachment') fids = att.search(cr, uid, [('parent_id','child_of',[int(dir)]),('change_type_id','=',int(type))], context=context) res[id] = { 'amount_required': 0, 'amount_exist': 0, 'amount_percent': 0.0 } for f in att.browse(cr, uid, fids, context=context): res[id] = { 'amount_required': res[id]['amount_required'] + 1, 'amount_exist': res[id]['amount_exist'] + (f.state<>'draft') and 1 or 0, } if res[id]['amount_required']: res[id]['amount_percent'] = float(res[id]['amount_exist']*100) / res[id]['amount_required'] return res
468,037
def get_product_available(self, cr, uid, ids, context=None): """ Finds whether product is available or not in particular warehouse. @return: Dictionary of values """ if context is None: context = {} states = context.get('states',[]) what = context.get('what',()) if not ids: ids = self.search(cr, uid, []) res = {}.fromkeys(ids, 0.0) if not ids: return res
def get_product_available(self, cr, uid, ids, context=None): """ Finds whether product is available or not in particular warehouse. @return: Dictionary of values """ if context is None: context = {} states = context.get('states',[]) what = context.get('what',()) if not ids: ids = self.search(cr, uid, []) res = {}.fromkeys(ids, 0.0) if not ids: return res
468,038
def get_product_available(self, cr, uid, ids, context=None): """ Finds whether product is available or not in particular warehouse. @return: Dictionary of values """ if context is None: context = {} states = context.get('states',[]) what = context.get('what',()) if not ids: ids = self.search(cr, uid, []) res = {}.fromkeys(ids, 0.0) if not ids: return res
def get_product_available(self, cr, uid, ids, context=None): """ Finds whether product is available or not in particular warehouse. @return: Dictionary of values """ if context is None: context = {} states = context.get('states',[]) what = context.get('what',()) if not ids: ids = self.search(cr, uid, []) res = {}.fromkeys(ids, 0.0) if not ids: return res
468,039
def _get_move_lines(self, cr, uid, ids, context=None): result = [] for move in self.pool.get('account.move').browse(cr, uid, ids, context=context): for line in move.line_id: result.append(line.id) return result
def _get_move_lines(self, cr, uid, ids, context=None): result = [] for move in self.pool.get('account.move').browse(cr, uid, ids, context=context): for line in move.line_id: result.append(line.id) return result
468,040
def action_produce_assign_service(self, cr, uid, ids, context={}): for procurement in self.browse(cr, uid, ids): sline = self.pool.get('sale.order.line') sale_ids = sline.search(cr, uid, [('procurement_id','=',procurement.id)], context) content = '' l = None project_id = None for line in sline.browse(cr, uid, sale_ids, context=context): content += (line.notes or '') l = line if line.order_id.project_id: content+="\n\n"+line.order_id.project_id.complete_name # Creating a project for task.Project is created from Procurement. proj_name = tools.ustr(procurement.name) proj_exist_id = self.pool.get('project.project').search(cr, uid, [('name','=',proj_name)], context=context) if not proj_exist_id: project_id = self.pool.get('project.project').create(cr, uid, {'name':proj_name}) else: project_id = proj_exist_id[0] self.write(cr, uid, [procurement.id], {'state':'running'}) task_id = self.pool.get('project.task').create(cr, uid, { 'name': '%s:%s' %(procurement.product_id.name or procurement.origin, procurement.name or ''), 'date_deadline': procurement.date_planned, 'planned_hours': procurement.product_qty, 'remaining_hours': procurement.product_qty, 'user_id': procurement.product_id.product_manager.id, 'notes': "b"+(l and l.order_id.note or ''), 'procurement_id': procurement.id, 'description': content, 'date_deadline': procurement.date_planned, 'state': 'draft', 'partner_id': l and l.order_id.partner_id.id or False, 'company_id': procurement.company_id.id, 'project_id': project_id, },context=context) return task_id
def action_produce_assign_service(self, cr, uid, ids, context={}): for procurement in self.browse(cr, uid, ids): sline = self.pool.get('sale.order.line') content = '' l = None project_id = None for line in sline.browse(cr, uid, sale_ids, context=context): content += (line.notes or '') l = line if line.order_id.project_id: content+="\n\n"+line.order_id.project_id.complete_name # Creating a project for task.Project is created from Procurement. proj_name = tools.ustr(procurement.name) proj_exist_id = self.pool.get('project.project').search(cr, uid, [('name','=',proj_name)], context=context) if not proj_exist_id: project_id = self.pool.get('project.project').create(cr, uid, {'name':proj_name}) else: project_id = proj_exist_id[0] self.write(cr, uid, [procurement.id], {'state':'running'}) task_id = self.pool.get('project.task').create(cr, uid, { 'name': '%s:%s' %(procurement.product_id.name or procurement.origin, procurement.name or ''), 'date_deadline': procurement.date_planned, 'planned_hours': procurement.product_qty, 'remaining_hours': procurement.product_qty, 'user_id': procurement.product_id.product_manager.id, 'notes': "b"+(l and l.order_id.note or ''), 'procurement_id': procurement.id, 'description': content, 'date_deadline': procurement.date_planned, 'state': 'draft', 'partner_id': l and l.order_id.partner_id.id or False, 'company_id': procurement.company_id.id, 'project_id': project_id, },context=context) return task_id
468,041
def action_produce_assign_service(self, cr, uid, ids, context={}): for procurement in self.browse(cr, uid, ids): sline = self.pool.get('sale.order.line') sale_ids = sline.search(cr, uid, [('procurement_id','=',procurement.id)], context) content = '' l = None project_id = None for line in sline.browse(cr, uid, sale_ids, context=context): content += (line.notes or '') l = line if line.order_id.project_id: content+="\n\n"+line.order_id.project_id.complete_name # Creating a project for task.Project is created from Procurement. proj_name = tools.ustr(procurement.name) proj_exist_id = self.pool.get('project.project').search(cr, uid, [('name','=',proj_name)], context=context) if not proj_exist_id: project_id = self.pool.get('project.project').create(cr, uid, {'name':proj_name}) else: project_id = proj_exist_id[0] self.write(cr, uid, [procurement.id], {'state':'running'}) task_id = self.pool.get('project.task').create(cr, uid, { 'name': '%s:%s' %(procurement.product_id.name or procurement.origin, procurement.name or ''), 'date_deadline': procurement.date_planned, 'planned_hours': procurement.product_qty, 'remaining_hours': procurement.product_qty, 'user_id': procurement.product_id.product_manager.id, 'notes': "b"+(l and l.order_id.note or ''), 'procurement_id': procurement.id, 'description': content, 'date_deadline': procurement.date_planned, 'state': 'draft', 'partner_id': l and l.order_id.partner_id.id or False, 'company_id': procurement.company_id.id, 'project_id': project_id, },context=context) return task_id
def action_produce_assign_service(self, cr, uid, ids, context={}): for procurement in self.browse(cr, uid, ids): sline = self.pool.get('sale.order.line') sale_ids = sline.search(cr, uid, [('procurement_id','=',procurement.id)], context) content = '' l = None project_id = None for line in sline.browse(cr, uid, sale_ids, context=context): content += (line.notes or '') l = line if line.order_id.project_id: content+="\n\n"+line.order_id.project_id.complete_name # Creating a project for task.Project is created from Procurement. proj_name = tools.ustr(so_ref) proj_exist_id = self.pool.get('project.project').search(cr, uid, [('name','=',proj_name)], context=context) if not proj_exist_id: project_id = self.pool.get('project.project').create(cr, uid, {'name':proj_name}) else: project_id = proj_exist_id[0] self.write(cr, uid, [procurement.id], {'state':'running'}) task_id = self.pool.get('project.task').create(cr, uid, { 'name': '%s:%s' %(procurement.product_id.name or procurement.origin, procurement.name or ''), 'date_deadline': procurement.date_planned, 'planned_hours': procurement.product_qty, 'remaining_hours': procurement.product_qty, 'user_id': procurement.product_id.product_manager.id, 'notes': "b"+(l and l.order_id.note or ''), 'procurement_id': procurement.id, 'description': content, 'date_deadline': procurement.date_planned, 'state': 'draft', 'partner_id': l and l.order_id.partner_id.id or False, 'company_id': procurement.company_id.id, 'project_id': project_id, },context=context) return task_id
468,042
def action_produce_assign_service(self, cr, uid, ids, context={}): for procurement in self.browse(cr, uid, ids): sline = self.pool.get('sale.order.line') sale_ids = sline.search(cr, uid, [('procurement_id','=',procurement.id)], context) content = '' l = None project_id = None for line in sline.browse(cr, uid, sale_ids, context=context): content += (line.notes or '') l = line if line.order_id.project_id: content+="\n\n"+line.order_id.project_id.complete_name # Creating a project for task.Project is created from Procurement. proj_name = tools.ustr(procurement.name) proj_exist_id = self.pool.get('project.project').search(cr, uid, [('name','=',proj_name)], context=context) if not proj_exist_id: project_id = self.pool.get('project.project').create(cr, uid, {'name':proj_name}) else: project_id = proj_exist_id[0] self.write(cr, uid, [procurement.id], {'state':'running'}) task_id = self.pool.get('project.task').create(cr, uid, { 'name': '%s:%s' %(procurement.product_id.name or procurement.origin, procurement.name or ''), 'date_deadline': procurement.date_planned, 'planned_hours': procurement.product_qty, 'remaining_hours': procurement.product_qty, 'user_id': procurement.product_id.product_manager.id, 'notes': "b"+(l and l.order_id.note or ''), 'procurement_id': procurement.id, 'description': content, 'date_deadline': procurement.date_planned, 'state': 'draft', 'partner_id': l and l.order_id.partner_id.id or False, 'company_id': procurement.company_id.id, 'project_id': project_id, },context=context) return task_id
def action_produce_assign_service(self, cr, uid, ids, context={}): for procurement in self.browse(cr, uid, ids): sline = self.pool.get('sale.order.line') sale_ids = sline.search(cr, uid, [('procurement_id','=',procurement.id)], context) content = '' l = None project_id = None for line in sline.browse(cr, uid, sale_ids, context=context): content += (line.notes or '') l = line if line.order_id.project_id: content+="\n\n"+line.order_id.project_id.complete_name # Creating a project for task.Project is created from Procurement. proj_name = tools.ustr(procurement.name) proj_exist_id = self.pool.get('project.project').search(cr, uid, [('name','=',proj_name)], context=context) if not proj_exist_id: project_id = self.pool.get('project.project').create(cr, uid, {'name':proj_name,'category_id':analytic_account_id, 'partner_id':partner_id}) else: project_id = proj_exist_id[0] self.write(cr, uid, [procurement.id], {'state':'running'}) task_id = self.pool.get('project.task').create(cr, uid, { 'name': '%s:%s' %(procurement.product_id.name or procurement.origin, procurement.name or ''), 'date_deadline': procurement.date_planned, 'planned_hours': procurement.product_qty, 'remaining_hours': procurement.product_qty, 'user_id': procurement.product_id.product_manager.id, 'notes': "b"+(l and l.order_id.note or ''), 'procurement_id': procurement.id, 'description': content, 'date_deadline': procurement.date_planned, 'state': 'draft', 'partner_id': l and l.order_id.partner_id.id or False, 'company_id': procurement.company_id.id, 'project_id': project_id, },context=context) return task_id
468,043
def action_produce_assign_service(self, cr, uid, ids, context={}): for procurement in self.browse(cr, uid, ids): sline = self.pool.get('sale.order.line') sale_ids = sline.search(cr, uid, [('procurement_id','=',procurement.id)], context) content = '' l = None project_id = None for line in sline.browse(cr, uid, sale_ids, context=context): content += (line.notes or '') l = line if line.order_id.project_id: content+="\n\n"+line.order_id.project_id.complete_name # Creating a project for task.Project is created from Procurement. proj_name = tools.ustr(procurement.name) proj_exist_id = self.pool.get('project.project').search(cr, uid, [('name','=',proj_name)], context=context) if not proj_exist_id: project_id = self.pool.get('project.project').create(cr, uid, {'name':proj_name}) else: project_id = proj_exist_id[0] self.write(cr, uid, [procurement.id], {'state':'running'}) task_id = self.pool.get('project.task').create(cr, uid, { 'name': '%s:%s' %(procurement.product_id.name or procurement.origin, procurement.name or ''), 'date_deadline': procurement.date_planned, 'planned_hours': procurement.product_qty, 'remaining_hours': procurement.product_qty, 'user_id': procurement.product_id.product_manager.id, 'notes': "b"+(l and l.order_id.note or ''), 'procurement_id': procurement.id, 'description': content, 'date_deadline': procurement.date_planned, 'state': 'draft', 'partner_id': l and l.order_id.partner_id.id or False, 'company_id': procurement.company_id.id, 'project_id': project_id, },context=context) return task_id
def action_produce_assign_service(self, cr, uid, ids, context={}): for procurement in self.browse(cr, uid, ids): sline = self.pool.get('sale.order.line') sale_ids = sline.search(cr, uid, [('procurement_id','=',procurement.id)], context) content = '' l = None project_id = None for line in sline.browse(cr, uid, sale_ids, context=context): content += (line.notes or '') l = line if line.order_id.project_id: content+="\n\n"+line.order_id.project_id.complete_name # Creating a project for task.Project is created from Procurement. proj_name = tools.ustr(procurement.name) proj_exist_id = self.pool.get('project.project').search(cr, uid, [('name','=',proj_name)], context=context) if not proj_exist_id: project_id = self.pool.get('project.project').create(cr, uid, {'name':proj_name}) else: project_id = proj_exist_id[0] self.write(cr, uid, [procurement.id], {'state':'running'}) task_id = self.pool.get('project.task').create(cr, uid, { 'name': '%s:%s' % name_task, 'date_deadline': procurement.date_planned, 'planned_hours': procurement.product_qty, 'remaining_hours': procurement.product_qty, 'user_id': procurement.product_id.product_manager.id, 'notes': "b"+(l and l.order_id.note or ''), 'procurement_id': procurement.id, 'description': content, 'date_deadline': procurement.date_planned, 'state': 'draft', 'partner_id': l and l.order_id.partner_id.id or False, 'company_id': procurement.company_id.id, 'project_id': project_id, },context=context) return task_id
468,044
def onchange_lot_id(self, cr, uid, ids, prodlot_id=False, product_qty=False, loc_id=False, product_id=False, context=None): """ On change of production lot gives a warning message. @param prodlot_id: Changed production lot id @param product_qty: Quantity of product @param loc_id: Location id @param product_id: Product id @return: Warning message """ if not prodlot_id or not loc_id: return {} ctx = context and context.copy() or {} ctx['location_id'] = loc_id prodlot = self.pool.get('stock.production.lot').browse(cr, uid, prodlot_id, ctx) location = self.pool.get('stock.location').browse(cr, uid, loc_id) warning = {} if (location.usage == 'internal') and (product_qty > (prodlot.stock_available or 0.0)): warning = { 'title': _('Insufficient Stock in Lot !'), 'message': _('You are moving %.2f products but only %.2f available in this lot.') % (product_qty, prodlot.stock_available or 0.0) } return {'warning': warning}
def onchange_lot_id(self, cr, uid, ids, prodlot_id=False, product_qty=False, loc_id=False, product_id=False, uom_id=False, context=None): """ On change of production lot gives a warning message. @param prodlot_id: Changed production lot id @param product_qty: Quantity of product @param loc_id: Location id @param product_id: Product id @return: Warning message """ if not prodlot_id or not loc_id: return {} ctx = context and context.copy() or {} ctx['location_id'] = loc_id prodlot = self.pool.get('stock.production.lot').browse(cr, uid, prodlot_id, ctx) location = self.pool.get('stock.location').browse(cr, uid, loc_id) warning = {} if (location.usage == 'internal') and (product_qty > (prodlot.stock_available or 0.0)): warning = { 'title': _('Insufficient Stock in Lot !'), 'message': _('You are moving %.2f products but only %.2f available in this lot.') % (product_qty, prodlot.stock_available or 0.0) } return {'warning': warning}
468,045
def onchange_lot_id(self, cr, uid, ids, prodlot_id=False, product_qty=False, loc_id=False, product_id=False, context=None): """ On change of production lot gives a warning message. @param prodlot_id: Changed production lot id @param product_qty: Quantity of product @param loc_id: Location id @param product_id: Product id @return: Warning message """ if not prodlot_id or not loc_id: return {} ctx = context and context.copy() or {} ctx['location_id'] = loc_id prodlot = self.pool.get('stock.production.lot').browse(cr, uid, prodlot_id, ctx) location = self.pool.get('stock.location').browse(cr, uid, loc_id) warning = {} if (location.usage == 'internal') and (product_qty > (prodlot.stock_available or 0.0)): warning = { 'title': _('Insufficient Stock in Lot !'), 'message': _('You are moving %.2f products but only %.2f available in this lot.') % (product_qty, prodlot.stock_available or 0.0) } return {'warning': warning}
def onchange_lot_id(self, cr, uid, ids, prodlot_id=False, product_qty=False, loc_id=False, product_id=False, context=None): """ On change of production lot gives a warning message. @param prodlot_id: Changed production lot id @param product_qty: Quantity of product @param loc_id: Location id @param product_id: Product id @return: Warning message """ if not prodlot_id or not loc_id: return {} ctx = context and context.copy() or {} ctx['location_id'] = loc_id prodlot = self.pool.get('stock.production.lot').browse(cr, uid, prodlot_id, ctx) location = self.pool.get('stock.location').browse(cr, uid, loc_id) warning = {} if (location.usage == 'internal') and (product_qty > (prodlot.stock_available or 0.0)): warning = { 'title': _('Insufficient Stock in Lot !'), 'message': _('You are moving %.2f %s products but only %.2f %s available in this lot.') % (product_qty, uom.name, prodlot.stock_available or 0.0, uom.name) } return {'warning': warning}
468,046
def onchange_uos_quantity(self, cr, uid, ids, product_id, product_uos_qty, product_uos, product_uom): """ On change of product quantity finds UoM and UoS quantities @param product_id: Product id @param product_uos_qty: Changed UoS Quantity of product @param product_uom: Unit of measure of product @param product_uos: Unit of sale of product @return: Dictionary of values """ result = { 'product_qty': 0.00 }
def onchange_uos_quantity(self, cr, uid, ids, product_id, product_uos_qty, product_uos, product_uom): """ On change of product quantity finds UoM and UoS quantities @param product_id: Product id @param product_uos_qty: Changed UoS Quantity of product @param product_uom: Unit of measure of product @param product_uos: Unit of sale of product @return: Dictionary of values """ result = { 'product_qty': 0.00 }
468,047
def _file_get(self,cr, nodename=False, directory_id=False): res = [] cntobj = self.context._dirobj.pool.get('document.directory.content') uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) where = [('directory_id','=',directory_id) ] ids = cntobj.search(cr, uid, where, context=ctx) for content in cntobj.browse(cr, uid, ids, context=ctx): res3 = cntobj._file_get(cr, self, nodename, content) if res3: res.extend(res3)
def _file_get(self,cr, nodename=False): res = [] cntobj = self.context._dirobj.pool.get('document.directory.content') uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) where = [('directory_id','=',directory_id) ] ids = cntobj.search(cr, uid, where, context=ctx) for content in cntobj.browse(cr, uid, ids, context=ctx): res3 = cntobj._file_get(cr, self, nodename, content) if res3: res.extend(res3)
468,048
def _file_get(self,cr, nodename=False, directory_id=False): res = [] cntobj = self.context._dirobj.pool.get('document.directory.content') uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) where = [('directory_id','=',directory_id) ] ids = cntobj.search(cr, uid, where, context=ctx) for content in cntobj.browse(cr, uid, ids, context=ctx): res3 = cntobj._file_get(cr, self, nodename, content) if res3: res.extend(res3)
def _file_get(self,cr, nodename=False, directory_id=False): res = [] cntobj = self.context._dirobj.pool.get('document.directory.content') uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) where = [('directory_id','=',directory_id) ] ids = cntobj.search(cr, uid, where, context=ctx) for content in cntobj.browse(cr, uid, ids, context=ctx): res3 = cntobj._file_get(cr, self, nodename, content) if res3: res.extend(res3)
468,049
def get_data(self, cr): res = '' for child in self.children(cr): res += child.get_data(cr) return res
def get_data(self, cr): res = '' for child in self.children(cr): res += child.get_data(cr) return res
468,050
def _file_get(self, cr, nodename=False): return super(node_dir,self)._file_get(cr, nodename, self.dir_id)
def _file_get(self, cr, nodename=False): return super(node_dir,self)._file_get(cr, nodename, self.dir_id)
468,051
def _create_new_share_users(self, cr, uid, wizard_data, group_id, context=None): user_obj = self.pool.get('res.users') current_user = user_obj.browse(cr, uid, uid) user_ids = [] if wizard_data.user_type == 'new': for new_user in wizard_data.new_users.split('\n'): # attempt to show more user-friendly msg than default constraint error existing = user_obj.search(cr, 1, [('login', '=', new_user)]) if existing: raise osv.except_osv(_('User already exists'), _('This username (%s) already exists, perhaps data has already been shared with this person.\nYou may want to try selecting existing shared users instead.')) user_id = user_obj.create(cr, 1, { 'login': new_user, 'password': generate_random_pass(), 'name': new_user, 'user_email': new_user, 'groups_id': [(6,0,[group_id])], 'share': True, 'company_id': current_user.company_id and current_user.company_id.id }) user_ids.append(user_id) return user_ids
def _create_new_share_users(self, cr, uid, wizard_data, group_id, context=None): user_obj = self.pool.get('res.users') current_user = user_obj.browse(cr, uid, uid) user_ids = [] if wizard_data.user_type == 'new': for new_user in wizard_data.new_users.split('\n'): # attempt to show more user-friendly msg than default constraint error existing = user_obj.search(cr, 1, [('login', '=', new_user)]) if existing: raise osv.except_osv(_('User already exists'), _('This username (%s) already exists, perhaps data has already been shared with this person.\nYou may want to try selecting existing shared users instead.')) user_id = user_obj.create(cr, 1, { 'login': new_user, 'password': password, 'name': new_user, 'user_email': new_user, 'groups_id': [(6,0,[group_id])], 'share': True, 'company_id': current_user.company_id and current_user.company_id.id }) user_ids.append(user_id) return user_ids
468,052
def go_step_2(self, cr, uid, ids, context=None): wizard_data = self.browse(cr, uid, ids and ids[0], context=context) assert wizard_data.action_id and wizard_data.access_mode and \ ((wizard_data.user_type == 'new' and wizard_data.new_users) or \ (wizard_data.user_type == 'existing' and wizard_data.user_ids))
defgo_step_2(self,cr,uid,ids,context=None):wizard_data=self.browse(cr,uid,idsandids[0],context=context)assertwizard_data.action_idandwizard_data.access_modeand\((wizard_data.user_type=='new'andwizard_data.new_users)or\(wizard_data.user_type=='existing'andwizard_data.user_ids))
468,053
def dispatch(self, method, auth, params): logger = netsvc.Logger() if method in [ 'ir_set','ir_del', 'ir_get' ]: return self.common_dispatch(method,auth,params) if method == 'login': # At this old dispatcher, we do NOT update the auth proxy res = security.login(params[0], params[1], params[2]) msg = res and 'successful login' or 'bad login or password' # TODO log the client ip address.. logger.notifyChannel("web-service", netsvc.LOG_INFO, "%s from '%s' using database '%s'" % (msg, params[1], params[0].lower())) return res or False elif method == 'logout': if auth: auth.logout(params[1]) logger.notifyChannel("web-service", netsvc.LOG_INFO,'Logout %s from database %s'%(login,db)) return True elif method in ['about', 'timezone_get', 'get_server_environment', 'login_message','get_stats', 'check_connectivity']: pass elif method in ['get_available_updates', 'get_migration_scripts', 'set_loglevel']: passwd = params[0] params = params[1:] security.check_super(passwd) else: raise Exception("Method not found: %s" % method) fn = getattr(self, 'exp_'+method) return fn(*params)
def dispatch(self, method, auth, params): logger = netsvc.Logger() if method in [ 'ir_set','ir_del', 'ir_get' ]: return self.common_dispatch(method,auth,params) if method == 'login': # At this old dispatcher, we do NOT update the auth proxy res = security.login(params[0], params[1], params[2]) msg = res and 'successful login' or 'bad login or password' # TODO log the client ip address.. logger.notifyChannel("web-service", netsvc.LOG_INFO, "%s from '%s' using database '%s'" % (msg, params[1], params[0].lower())) return res or False elif method == 'logout': if auth: auth.logout(params[1]) logger.notifyChannel("web-service", netsvc.LOG_INFO,'Logout %s from database %s'%(login,db)) return True elif method in ['about', 'timezone_get', 'get_server_environment', 'login_message','get_stats', 'check_connectivity', 'list_http_services']: pass elif method in ['get_available_updates', 'get_migration_scripts', 'set_loglevel']: passwd = params[0] params = params[1:] security.check_super(passwd) else: raise Exception("Method not found: %s" % method) fn = getattr(self, 'exp_'+method) return fn(*params)
468,054
def __getitem__(self, name): if name == 'id': return self._id if name not in self._data[self._id]: # build the list of fields we will fetch
def __getitem__(self, name): if name == 'id': return self._id if name not in self._data[self._id]: # build the list of fields we will fetch
468,055
def __getitem__(self, name): if name == 'id': return self._id if name not in self._data[self._id]: # build the list of fields we will fetch
def __getitem__(self, name): if name == 'id': return self._id if name not in self._data[self._id]: # build the list of fields we will fetch
468,056
def _tag_report(self, cr, rec, data_node=None): res = {} for dest,f in (('name','string'),('model','model'),('report_name','name')): res[dest] = rec.get(f,'').encode('utf8') assert res[dest], "Attribute %s of report is empty !" % (f,) for field,dest in (('rml','report_rml'),('file','report_file'),('xml','report_xml'),('xsl','report_xsl'),('attachment','attachment'),('attachment_use','attachment_use')): if rec.get(field): res[dest] = rec.get(field).encode('utf8') if rec.get('auto'): res['auto'] = eval(rec.get('auto','False')) if rec.get('sxw'): sxw_content = misc.file_open(rec.get('sxw')).read() res['report_sxw_content'] = sxw_content if rec.get('header'): res['header'] = eval(rec.get('header','False')) if rec.get('report_type'): res['report_type'] = rec.get('report_type')
def _tag_report(self, cr, rec, data_node=None): res = {} for dest,f in (('name','string'),('model','model'),('report_name','name')): res[dest] = rec.get(f,'').encode('utf8') assert res[dest], "Attribute %s of report is empty !" % (f,) for field,dest in (('rml','report_rml'),('file','report_rml'),('xml','report_xml'),('xsl','report_xsl'),('attachment','attachment'),('attachment_use','attachment_use')): if rec.get(field): res[dest] = rec.get(field).encode('utf8') if rec.get('auto'): res['auto'] = eval(rec.get('auto','False')) if rec.get('sxw'): sxw_content = misc.file_open(rec.get('sxw')).read() res['report_sxw_content'] = sxw_content if rec.get('header'): res['header'] = eval(rec.get('header','False')) if rec.get('report_type'): res['report_type'] = rec.get('report_type')
468,057
def set_context(self, objects, data, ids, report_type = None): self.localcontext['data'] = data self.localcontext['objects'] = objects self.localcontext['digits_fmt'] = self.digits_fmt self.localcontext['get_digits'] = self.get_digits self.datas = data self.ids = ids self.objects = objects if report_type: if report_type=='odt' : self.localcontext.update({'name_space' :common.odt_namespace}) else: self.localcontext.update({'name_space' :common.sxw_namespace})
def set_context(self, objects, data, ids, report_type = None): self.localcontext['data'] = data self.localcontext['objects'] = objects self.localcontext['digits_fmt'] = self.digits_fmt self.localcontext['get_digits'] = self.get_digits self.datas = data self.ids = ids self.objects = objects if report_type: if report_type=='odt' : self.localcontext.update({'name_space' :common.odt_namespace}) else: self.localcontext.update({'name_space' :common.sxw_namespace})
468,058
def create_order(self, cr, uid, ids, context): """ To Create a purchase orders . @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID or list of IDs @param context: A standard dictionary @return: {} """ record_ids = context and context.get('active_ids', False) if record_ids: data = self.read(cr, uid, ids) company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id order_obj = self.pool.get('purchase.order') order_line_obj = self.pool.get('purchase.order.line') partner_obj = self.pool.get('res.partner') tender_line_obj = self.pool.get('purchase.requisition.line') pricelist_obj = self.pool.get('product.pricelist') prod_obj = self.pool.get('product.product') tender_obj = self.pool.get('purchase.requisition') acc_pos_obj = self.pool.get('account.fiscal.position') partner_id = data[0]['partner_id'] address_id = partner_obj.address_get(cr, uid, [partner_id], ['delivery'])['delivery'] list_line=[] purchase_order_line={} for tender in tender_obj.browse(cr, uid, record_ids): for line in tender.line_ids: uom_id = line.product_id.uom_po_id.id newdate = DateTime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S') newdate = newdate - DateTime.RelativeDateTime(days=company.po_lead) newdate = newdate - line.product_id.seller_ids[0].delay
def create_order(self, cr, uid, ids, context): """ To Create a purchase orders . @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID or list of IDs @param context: A standard dictionary @return: {} """ record_ids = context and context.get('active_ids', False) if record_ids: data = self.read(cr, uid, ids) company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id order_obj = self.pool.get('purchase.order') order_line_obj = self.pool.get('purchase.order.line') partner_obj = self.pool.get('res.partner') tender_line_obj = self.pool.get('purchase.requisition.line') pricelist_obj = self.pool.get('product.pricelist') prod_obj = self.pool.get('product.product') tender_obj = self.pool.get('purchase.requisition') acc_pos_obj = self.pool.get('account.fiscal.position') partner_id = data[0]['partner_id'] address_id = partner_obj.address_get(cr, uid, [partner_id], ['delivery'])['delivery'] list_line=[] purchase_order_line={} for tender in tender_obj.browse(cr, uid, record_ids): for line in tender.line_ids: uom_id = line.product_id.uom_po_id and line.product_id.uom_po_id.id or False newdate = DateTime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S') newdate = newdate - DateTime.RelativeDateTime(days=company.po_lead) newdate = newdate - line.product_id.seller_ids[0].delay
468,059
def create_order(self, cr, uid, ids, context): """ To Create a purchase orders . @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID or list of IDs @param context: A standard dictionary @return: {} """ record_ids = context and context.get('active_ids', False) if record_ids: data = self.read(cr, uid, ids) company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id order_obj = self.pool.get('purchase.order') order_line_obj = self.pool.get('purchase.order.line') partner_obj = self.pool.get('res.partner') tender_line_obj = self.pool.get('purchase.requisition.line') pricelist_obj = self.pool.get('product.pricelist') prod_obj = self.pool.get('product.product') tender_obj = self.pool.get('purchase.requisition') acc_pos_obj = self.pool.get('account.fiscal.position') partner_id = data[0]['partner_id'] address_id = partner_obj.address_get(cr, uid, [partner_id], ['delivery'])['delivery'] list_line=[] purchase_order_line={} for tender in tender_obj.browse(cr, uid, record_ids): for line in tender.line_ids: uom_id = line.product_id.uom_po_id.id newdate = DateTime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S') newdate = newdate - DateTime.RelativeDateTime(days=company.po_lead) newdate = newdate - line.product_id.seller_ids[0].delay
def create_order(self, cr, uid, ids, context): """ To Create a purchase orders . @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID or list of IDs @param context: A standard dictionary @return: {} """ record_ids = context and context.get('active_ids', False) if record_ids: data = self.read(cr, uid, ids) company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id order_obj = self.pool.get('purchase.order') order_line_obj = self.pool.get('purchase.order.line') partner_obj = self.pool.get('res.partner') tender_line_obj = self.pool.get('purchase.requisition.line') pricelist_obj = self.pool.get('product.pricelist') prod_obj = self.pool.get('product.product') tender_obj = self.pool.get('purchase.requisition') acc_pos_obj = self.pool.get('account.fiscal.position') partner_id = data[0]['partner_id'] address_id = partner_obj.address_get(cr, uid, [partner_id], ['delivery'])['delivery'] list_line=[] purchase_order_line={} for tender in tender_obj.browse(cr, uid, record_ids): for line in tender.line_ids: uom_id = line.product_id.uom_po_id.id newdate = DateTime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S') newdate = newdate - DateTime.RelativeDateTime(days=company.po_lead) newdate = newdate - line.product_id.seller_ids[0].delay
468,060
def create_order(self, cr, uid, ids, context): """ To Create a purchase orders . @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID or list of IDs @param context: A standard dictionary @return: {} """ record_ids = context and context.get('active_ids', False) if record_ids: data = self.read(cr, uid, ids) company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id order_obj = self.pool.get('purchase.order') order_line_obj = self.pool.get('purchase.order.line') partner_obj = self.pool.get('res.partner') tender_line_obj = self.pool.get('purchase.requisition.line') pricelist_obj = self.pool.get('product.pricelist') prod_obj = self.pool.get('product.product') tender_obj = self.pool.get('purchase.requisition') acc_pos_obj = self.pool.get('account.fiscal.position') partner_id = data[0]['partner_id'] address_id = partner_obj.address_get(cr, uid, [partner_id], ['delivery'])['delivery'] list_line=[] purchase_order_line={} for tender in tender_obj.browse(cr, uid, record_ids): for line in tender.line_ids: uom_id = line.product_id.uom_po_id.id newdate = DateTime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S') newdate = newdate - DateTime.RelativeDateTime(days=company.po_lead) newdate = newdate - line.product_id.seller_ids[0].delay
def create_order(self, cr, uid, ids, context): """ To Create a purchase orders . @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID or list of IDs @param context: A standard dictionary @return: {} """ record_ids = context and context.get('active_ids', False) if record_ids: data = self.read(cr, uid, ids) company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id order_obj = self.pool.get('purchase.order') order_line_obj = self.pool.get('purchase.order.line') partner_obj = self.pool.get('res.partner') tender_line_obj = self.pool.get('purchase.requisition.line') pricelist_obj = self.pool.get('product.pricelist') prod_obj = self.pool.get('product.product') tender_obj = self.pool.get('purchase.requisition') acc_pos_obj = self.pool.get('account.fiscal.position') partner_id = data[0]['partner_id'] address_id = partner_obj.address_get(cr, uid, [partner_id], ['delivery'])['delivery'] list_line=[] purchase_order_line={} for tender in tender_obj.browse(cr, uid, record_ids): for line in tender.line_ids: uom_id = line.product_id.uom_po_id.id newdate = DateTime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S') newdate = newdate - DateTime.RelativeDateTime(days=company.po_lead) newdate = newdate - line.product_id.seller_ids[0].delay
468,061
def ics_datetime(idate, short=False): if short: return date.fromtimestamp(time.mktime(time.strptime(idate, '%Y-%m-%d'))) else: return datetime.strptime(idate, '%Y-%m-%d %H:%M:%S')
def ics_datetime(idate, short=False): if idate: if short: return date.fromtimestamp(time.mktime(time.strptime(idate, '%Y-%m-%d'))) else: return datetime.strptime(idate, '%Y-%m-%d %H:%M:%S') else: return datetime.strptime(idate, '%Y-%m-%d %H:%M:%S')
468,062
def ics_datetime(idate, short=False): if short: return date.fromtimestamp(time.mktime(time.strptime(idate, '%Y-%m-%d'))) else: return datetime.strptime(idate, '%Y-%m-%d %H:%M:%S')
def ics_datetime(idate, short=False): if short: return date.fromtimestamp(time.mktime(time.strptime(idate, '%Y-%m-%d'))) else: return datetime.strptime(idate, '%Y-%m-%d %H:%M:%S')
468,063
def _send_mail(self, cr, uid, ids, mail_to, email_from=tools.config.get('email_from', False), context=None): """ Send mail for event invitation to event attendees. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of attendee’s IDs. @param email_from: Email address for user sending the mail @param context: A standard dictionary for contextual values @return: True """ if not context: context = {}
def _send_mail(self, cr, uid, ids, mail_to, email_from=tools.config.get('email_from', False), context=None): """ Send mail for event invitation to event attendees. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of attendee’s IDs. @param email_from: Email address for user sending the mail @param context: A standard dictionary for contextual values @return: True """ if not context: context = {}
468,064
def _send_mail(self, cr, uid, ids, mail_to, email_from=tools.config.get('email_from', False), context=None): """ Send mail for event invitation to event attendees. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of attendee’s IDs. @param email_from: Email address for user sending the mail @param context: A standard dictionary for contextual values @return: True """ if not context: context = {}
def _send_mail(self, cr, uid, ids, mail_to, email_from=tools.config.get('email_from', False), context=None): """ Send mail for event invitation to event attendees. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of attendee’s IDs. @param email_from: Email address for user sending the mail @param context: A standard dictionary for contextual values @return: True """ if not context: context = {}
468,065
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None): groupby_list = groupby groupby = groupby[0] context = context or {} self.pool.get('ir.model.access').check(cr, uid, self._name, 'read', context=context) if not fields: fields = self._columns.keys()
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None): groupby_list = groupby if isinstance(groupby, list): groupby = groupby[0] context = context or {} self.pool.get('ir.model.access').check(cr, uid, self._name, 'read', context=context) if not fields: fields = self._columns.keys()
468,066
def make_po(self, cr, uid, ids, context={}): sequence_obj=self.pool.get('ir.sequence') res = super(mrp_procurement, self).make_po(cr, uid, ids, context) for proc_id,po_id in res.items(): procurement = self.browse(cr, uid, proc_id) if procurement.product_id.purchase_requisition: self.pool.get('purchase.requisition').create(cr, uid, { 'name': procurement.name, 'origin': procurement.name, 'date_end': procurement.date_planned, 'lines_ids': [(0,0,{ 'product_id': procurement.product_id.id, 'product_uom_id': procurement.product_uom.id, 'product_qty': procurement.product_qty
def make_po(self, cr, uid, ids, context={}): sequence_obj=self.pool.get('ir.sequence') res = super(mrp_procurement, self).make_po(cr, uid, ids, context) for proc_id,po_id in res.items(): procurement = self.browse(cr, uid, proc_id) if procurement.product_id.purchase_requisition: self.pool.get('purchase.requisition').create(cr, uid, { 'name': procurement.name, 'origin': procurement.name, 'date_end': procurement.date_planned, 'line_ids': [(0,0,{ 'product_id': procurement.product_id.id, 'product_uom_id': procurement.product_uom.id, 'product_qty': procurement.product_qty
468,067
def get(self, cr, obj, ids, name, user=None, context=None, values=None): if not context: context = {} if not values: values = {} res = {} if self._method: res = self._fnct(obj, cr, user, ids, name, self._arg, context) else: res = self._fnct(cr, obj._table, ids, name, self._arg, context)
def get(self, cr, obj, ids, name, user=None, context=None, values=None): if not context: context = {} if not values: values = {} res = {} if self._method: res = self._fnct(obj, cr, user, ids, name, self._arg, context) else: res = self._fnct(cr, obj._table, ids, name, self._arg, context)
468,068
def create_analytic_lines(self, cr, uid, ids, context={}): super(account_move_line, self).create_analytic_lines(cr, uid, ids, context) for line in self.browse(cr, uid, ids, context): if line.analytics_id: if not line.journal_id.analytic_journal_id: raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (line.journal_id.name,))
def create_analytic_lines(self, cr, uid, ids, context={}): super(account_move_line, self).create_analytic_lines(cr, uid, ids, context) for line in self.browse(cr, uid, ids, context): if line.analytics_id: if not line.journal_id.analytic_journal_id: raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (line.journal_id.name,))
468,069
def create_analytic_lines(self, cr, uid, ids, context={}): super(account_move_line, self).create_analytic_lines(cr, uid, ids, context) for line in self.browse(cr, uid, ids, context): if line.analytics_id: if not line.journal_id.analytic_journal_id: raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (line.journal_id.name,))
def create_analytic_lines(self, cr, uid, ids, context={}): super(account_move_line, self).create_analytic_lines(cr, uid, ids, context) for line in self.browse(cr, uid, ids, context): if line.analytics_id: if not line.journal_id.analytic_journal_id: raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (line.journal_id.name,))
468,070
def create_analytic_lines(self, cr, uid, ids, context={}): super(account_move_line, self).create_analytic_lines(cr, uid, ids, context) for line in self.browse(cr, uid, ids, context): if line.analytics_id: if not line.journal_id.analytic_journal_id: raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (line.journal_id.name,))
def create_analytic_lines(self, cr, uid, ids, context={}): super(account_move_line, self).create_analytic_lines(cr, uid, ids, context) for line in self.browse(cr, uid, ids, context): if line.analytics_id: if not line.journal_id.analytic_journal_id: raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (line.journal_id.name,))
468,071
def launch_wizard(self, cr, uid, ids, context=None): """ Search for a wizard to launch according to the type. If type is manual. just confirm the order. """ obj_payment_order = self.pool.get('payment.order') obj_model = self.pool.get('ir.model.data') obj_act = self.pool.get('ir.actions.act_window') order= obj_payment_order.browse(cr, uid, context['active_id'], context) t = order.mode and order.mode.type.code or 'manual' if t == 'manual' : obj_payment_order.set_done(cr,uid,context['active_id'],context) return {}
def launch_wizard(self, cr, uid, ids, context=None): """ Search for a wizard to launch according to the type. If type is manual. just confirm the order. """ obj_payment_order = self.pool.get('payment.order') obj_model = self.pool.get('ir.model.data') obj_act = self.pool.get('ir.actions.act_window') order= obj_payment_order.browse(cr, uid, context['active_id'], context) t = order.mode and order.mode.type.code or 'manual' if t == 'manual' : obj_payment_order.set_done(cr,uid,context['active_id'],context) return {}
468,072
def load_information_from_description_file(module): """ :param module: The name of the module (sale, purchase, ...) """ for filename in ['__openerp__.py', '__terp__.py']: description_file = addons.get_module_resource(module, filename) if os.path.isfile(description_file): return eval(tools.file_open(description_file).read()) logging.warning('The module %s does not contain a description file: __openerp__.py or __terp__.py (deprecated)' % module) return {}
def load_information_from_description_file(module): """ :param module: The name of the module (sale, purchase, ...) """ for filename in ['__openerp__.py', '__terp__.py']: description_file = addons.get_module_resource(module, filename) if os.path.isfile(description_file): return eval(tools.file_open(description_file).read()) logging.getLogger('addons').debug('The module %s does not contain a description file:'\ '__openerp__.py or __terp__.py (deprecated)', module) return {}
468,073
def _get_period(self, cr, uid, context=None): """Return default period value""" return self.pool.get('account.period').find(cr, uid)
def _get_period(self, cr, uid, context=None): """Return default period value""" return self.pool.get('account.period').find(cr, uid)
468,074
def _rec_convert(ids): if field_obj == table: return ids return self.__execute_recursive_in(cr, field._id1, field._rel, field._id2, ids, operator, field._type)
def _rec_convert(ids): if field_obj == table: return ids return self.__execute_recursive_in(cr, field._id1, field._rel, field._id2, ids, operator, field._type)
468,075
def process_imp_ics(self, cr, uid, ids, context=None): """ Process Import ics File. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of calendar event import’s IDs @return: dictionary of calendar evet import window with Import successful msg. """
def process_imp_ics(self, cr, uid, ids, context=None): """ Process Import ics File. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of calendar event import’s IDs @return: dictionary of calendar evet import window with Import successful msg. """
468,076
def _centralise(self, cr, uid, move, mode, context=None): if context is None: context = {}
def _centralise(self, cr, uid, move, mode, context=None): if context is None: context = {}
468,077
def _latestmodification(self, cr, uid, ids, field_name, arg, context={}): res = {} #TODOto calculate latest modified date from all related documents return res
def _latestmodification(self, cr, uid, ids, field_name, arg, context={}): res = {} #TODOto calculate latest modified date from all related documents return res
468,078
def _latestmodification(self, cr, uid, ids, field_name, arg, context={}): res = {} #TODOto calculate latest modified date from all related documents return res
def _latestmodification(self, cr, uid, ids, field_name, arg, context={}): res = {} #TODOto calculate latest modified date from all related documents return res
468,079
def change_prod_qty(self, cr, uid, ids, context): """ Changes the Quantity of Product. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: List of IDs selected @param context: A standard dictionary @return: """ record_id = context and context.get('active_id',False) assert record_id, _('Active Id is not found') prod_obj = self.pool.get('mrp.production') product_lines_obj = self.pool.get('mrp.production.product.line') bom_obj = self.pool.get('mrp.bom') for wiz_qty in self.browse(cr, uid, ids): prod = prod_obj.browse(cr, uid,record_id) prod_obj.write(cr, uid,prod.id, {'product_qty': wiz_qty.product_qty}) prod_obj.action_compute(cr, uid, [prod.id]) move_lines_obj = self.pool.get('stock.move') for move in prod.move_lines: bom_point = prod.bom_id bom_id = prod.bom_id.id if not bom_point: bom_id = bom_obj._bom_find(cr, uid, prod.product_id.id, prod.product_uom.id) if not bom_id: raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product")) prod_obj.write(cr, uid, [prod.id], {'bom_id': bom_id}) bom_point = sbom_obj.browse(cr, uid, [bom_id])[0] if not bom_id: raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product")) factor = prod.product_qty * prod.product_uom.factor / bom_point.product_uom.factor res = bom_obj._bom_explode(cr, uid, bom_point, factor / bom_point.product_qty, []) for r in res[0]: if r['product_id']== move.product_id.id: move_lines_obj.write(cr, uid,move.id, {'product_qty' : r['product_qty']}) for m in prod.move_created_ids: move_lines_obj.write(cr, uid,m.id, {'product_qty': wiz_qty.product_qty}) return {}
def change_prod_qty(self, cr, uid, ids, context): """ Changes the Quantity of Product. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: List of IDs selected @param context: A standard dictionary @return: """ record_id = context and context.get('active_id',False) assert record_id, _('Active Id is not found') prod_obj = self.pool.get('mrp.production') product_lines_obj = self.pool.get('mrp.production.product.line') bom_obj = self.pool.get('mrp.bom') for wiz_qty in self.browse(cr, uid, ids): prod = prod_obj.browse(cr, uid,record_id) prod_obj.write(cr, uid,prod.id, {'product_qty': wiz_qty.product_qty}) prod_obj.action_compute(cr, uid, [prod.id]) move_lines_obj = self.pool.get('stock.move') for move in prod.move_lines: bom_point = prod.bom_id bom_id = prod.bom_id.id if not bom_point: bom_id = bom_obj._bom_find(cr, uid, prod.product_id.id, prod.product_uom.id) if not bom_id: raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product")) prod_obj.write(cr, uid, [prod.id], {'bom_id': bom_id}) bom_point = bom_obj.browse(cr, uid, [bom_id])[0] if not bom_id: raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product")) factor = prod.product_qty * prod.product_uom.factor / bom_point.product_uom.factor res = bom_obj._bom_explode(cr, uid, bom_point, factor / bom_point.product_qty, []) for r in res[0]: if r['product_id']== move.product_id.id: move_lines_obj.write(cr, uid,move.id, {'product_qty' : r['product_qty']}) for m in prod.move_created_ids: move_lines_obj.write(cr, uid,m.id, {'product_qty': wiz_qty.product_qty}) return {}
468,080
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
468,081
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
468,082
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
468,083
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
468,084
def write(self, cr, uid, ids, vals, context=None): if not context: context={} group_id = self.pool.get('res.groups').search(cr, uid, [('name', 'in', ('Administration / Configuration','Administration / Access Rights'))]) user_obj = self.pool.get('res.users') group=[] user_rec = user_obj.read(cr, uid, uid) for move in self.browse(cr, uid, ids): if move.state=='done': group=[i for i in group_id if (i and (i not in user_rec['groups_id']))] if group: raise osv.except_osv(_('Error!'), _('Quantities, UoMs, Products and Locations cannot be modified on stock moves in Done state (except by the Administrator ' )) return super(stock_move, self).write(cr, uid, ids, vals, context=context)
def write(self, cr, uid, ids, vals, context=None): if uid != 1: for move in self.browse(cr, uid, ids): if move.state == 'done': frozen_fields = set(['product_qty', 'product_uom', 'product_uos_qty', 'product_uos', 'location_id', 'location_dest_id', 'product_id']) if frozen_fields.intersection(vals): raise osv.except_osv(_('Operation forbidden'), _('Quantities, UoMs, Products and Locations cannot be modified on stock moves that have already been processed (except by the Administrator)')) return super(stock_move, self).write(cr, uid, ids, vals, context=context)
468,085
def write(self, cr, uid, ids, vals, context=None): if not context: context={} group_id = self.pool.get('res.groups').search(cr, uid, [('name', 'in', ('Administration / Configuration','Administration / Access Rights'))]) user_obj = self.pool.get('res.users') group=[] user_rec = user_obj.read(cr, uid, uid) for move in self.browse(cr, uid, ids): if move.state=='done': group=[i for i in group_id if (i and (i not in user_rec['groups_id']))] if group: raise osv.except_osv(_('Error!'), _('Quantities, UoMs, Products and Locations cannot be modified on stock moves in Done state (except by the Administrator ' )) return super(stock_move, self).write(cr, uid, ids, vals, context=context)
def write(self, cr, uid, ids, vals, context=None): if not context: context={} group_id = self.pool.get('res.groups').search(cr, uid, [('name', 'in', ('Administration / Configuration','Administration / Access Rights'))]) user_obj = self.pool.get('res.users') group=[] user_rec = user_obj.read(cr, uid, uid) for move in self.browse(cr, uid, ids): if move.state=='done': group=[i for i in group_id if (i and (i not in user_rec['groups_id']))] if group: raise osv.except_osv(_('Error!'), _('Quantities, UoMs, Products and Locations cannot be modified on stock moves in Done state (except by the Administrator ' )) return super(stock_move, self).write(cr, uid, ids, vals, context=context)
468,086
def stage_next(self, cr, uid, ids, context=None): """This function computes next stage for case from its current stage using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') current_seq = False for case in self.browse(cr, uid, ids, context): next_stage = False data = {} domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) stages = stage_pool.search(cr, uid, domain, order='sequence') index = -1 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) if index + 1 == len(stages): return False else: next_stage = stages[index + 1] current_seq = case.stage_id.sequence if next_stage: stage = stage_pool.browse(cr, uid, next_stage, context=context) next_seq = stage.sequence if current_seq and (next_seq - current_seq) >= 1: data = {'stage_id': next_stage} if stage.on_change: data.update({'probability': stage.probability}) self.write(cr, uid, [case.id], data, context=context) return next_stage
def _find_next_stage(self, cr, uid, stage_list, index, current_seq, stage_pool, context=None): if index + 1 == len(stage_list): return False print "cul" print index next_stage_id = stage_list[index + 1] next_stage = stage_pool.browse(cr, uid, next_stage_id, context=context) if not next_stage: return False next_seq = next_stage.sequence if (abs(next_seq - current_seq)) >= 1: print next_stage return next_stage else : return _find_next_stage(cr, uid, stage_list, index + 1, current_seq, stage_pool) def stage_change(self, cr, uid, ids, context=None, order='sequence'): if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') current_seq = False for case in self.browse(cr, uid, ids, context): next_stage = False data = {} domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) stages = stage_pool.search(cr, uid, domain, order='sequence') index = -1 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) if index + 1 == len(stages): return False else: next_stage = stages[index + 1] current_seq = case.stage_id.sequence if next_stage: stage = stage_pool.browse(cr, uid, next_stage, context=context) next_seq = stage.sequence if current_seq and (next_seq - current_seq) >= 1: data = {'stage_id': next_stage} if stage.on_change: data.update({'probability': stage.probability}) self.write(cr, uid, [case.id], data, context=context) return next_stage
468,087
def stage_next(self, cr, uid, ids, context=None): """This function computes next stage for case from its current stage using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') current_seq = False for case in self.browse(cr, uid, ids, context): next_stage = False data = {} domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) stages = stage_pool.search(cr, uid, domain, order='sequence') index = -1 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) if index + 1 == len(stages): return False else: next_stage = stages[index + 1] current_seq = case.stage_id.sequence if next_stage: stage = stage_pool.browse(cr, uid, next_stage, context=context) next_seq = stage.sequence if current_seq and (next_seq - current_seq) >= 1: data = {'stage_id': next_stage} if stage.on_change: data.update({'probability': stage.probability}) self.write(cr, uid, [case.id], data, context=context) return next_stage
def stage_next(self, cr, uid, ids, context=None): """This function computes next stage for case from its current stage using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') current_seq = False for case in self.browse(cr, uid, ids, context): next_stage = False data = {} domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) stages = stage_pool.search(cr, uid, domain, order=order) current_seq = case.stage_id.sequence index = -1 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) if index + 1 == len(stages): return False else: next_stage = stages[index + 1] current_seq = case.stage_id.sequence if next_stage: stage = stage_pool.browse(cr, uid, next_stage, context=context) next_seq = stage.sequence if current_seq and (next_seq - current_seq) >= 1: data = {'stage_id': next_stage} if stage.on_change: data.update({'probability': stage.probability}) self.write(cr, uid, [case.id], data, context=context) return next_stage
468,088
def stage_next(self, cr, uid, ids, context=None): """This function computes next stage for case from its current stage using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') current_seq = False for case in self.browse(cr, uid, ids, context): next_stage = False data = {} domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) stages = stage_pool.search(cr, uid, domain, order='sequence') index = -1 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) if index + 1 == len(stages): return False else: next_stage = stages[index + 1] current_seq = case.stage_id.sequence if next_stage: stage = stage_pool.browse(cr, uid, next_stage, context=context) next_seq = stage.sequence if current_seq and (next_seq - current_seq) >= 1: data = {'stage_id': next_stage} if stage.on_change: data.update({'probability': stage.probability}) self.write(cr, uid, [case.id], data, context=context) return next_stage
def stage_next(self, cr, uid, ids, context=None): """This function computes next stage for case from its current stage using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') current_seq = False for case in self.browse(cr, uid, ids, context): next_stage = False data = {} domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) stages = stage_pool.search(cr, uid, domain, order='sequence') index = -1 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) print stages print "call" next_stage = self._find_next_stage(cr, uid, stages, index, current_seq, stage_pool, context=context) if next_stage: stage = stage_pool.browse(cr, uid, next_stage, context=context) next_seq = stage.sequence if current_seq and (next_seq - current_seq) >= 1: data = {'stage_id': next_stage} if stage.on_change: data.update({'probability': stage.probability}) self.write(cr, uid, [case.id], data, context=context) return next_stage
468,089
def stage_next(self, cr, uid, ids, context=None): """This function computes next stage for case from its current stage using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') current_seq = False for case in self.browse(cr, uid, ids, context): next_stage = False data = {} domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) stages = stage_pool.search(cr, uid, domain, order='sequence') index = -1 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) if index + 1 == len(stages): return False else: next_stage = stages[index + 1] current_seq = case.stage_id.sequence if next_stage: stage = stage_pool.browse(cr, uid, next_stage, context=context) next_seq = stage.sequence if current_seq and (next_seq - current_seq) >= 1: data = {'stage_id': next_stage} if stage.on_change: data.update({'probability': stage.probability}) self.write(cr, uid, [case.id], data, context=context) return next_stage
def stage_next(self, cr, uid, ids, context=None): """This function computes next stage for case from its current stage using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') current_seq = False for case in self.browse(cr, uid, ids, context): next_stage = False data = {} domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) stages = stage_pool.search(cr, uid, domain, order='sequence') index = -1 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) if index + 1 == len(stages): return False else: next_stage = stages[index + 1] current_seq = case.stage_id.sequence if next_stage: next_stage_id = next_stage.id data = {'stage_id': next_stage.id} if next_stage.on_change: data.update({'probability': next_stage.probability}) self.write(cr, uid, [case.id], data, context=context) return next_stage
468,090
def stage_next(self, cr, uid, ids, context=None): """This function computes next stage for case from its current stage using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') current_seq = False for case in self.browse(cr, uid, ids, context): next_stage = False data = {} domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) stages = stage_pool.search(cr, uid, domain, order='sequence') index = -1 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) if index + 1 == len(stages): return False else: next_stage = stages[index + 1] current_seq = case.stage_id.sequence if next_stage: stage = stage_pool.browse(cr, uid, next_stage, context=context) next_seq = stage.sequence if current_seq and (next_seq - current_seq) >= 1: data = {'stage_id': next_stage} if stage.on_change: data.update({'probability': stage.probability}) self.write(cr, uid, [case.id], data, context=context) return next_stage
def stage_next(self, cr, uid, ids, context=None): """This function computes next stage for case from its current stage using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') current_seq = False for case in self.browse(cr, uid, ids, context): next_stage = False data = {} domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) stages = stage_pool.search(cr, uid, domain, order='sequence') index = -1 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) if index + 1 == len(stages): return False else: next_stage = stages[index + 1] current_seq = case.stage_id.sequence if next_stage: stage = stage_pool.browse(cr, uid, next_stage, context=context) next_seq = stage.sequence if current_seq and (next_seq - current_seq) >= 1: data = {'stage_id': next_stage} if stage.on_change: data.update({'probability': stage.probability}) self.write(cr, uid, [case.id], data, context=context) return next_stage
468,091
def stage_previous(self, cr, uid, ids, context=None): """This function computes previous stage for case from its current stage using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') for case in self.browse(cr, uid, ids, context): prev_stage = False data = {} domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) stages = stage_pool.search(cr, uid, domain, order='sequence') index = 0 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) if index == 0: return False else: prev_stage = stages[index - 1] current_seq = case.stage_id.sequence if prev_stage: stage = stage_pool.browse(cr, uid, prev_stage, context=context) prev_seq = stage.sequence if current_seq and (prev_seq - current_seq) <= 1: data = {'stage_id': prev_stage} if stage.on_change: data.update({'probability': stage.probability}) self.write(cr, uid, [case.id], data, context=context) return prev_stage
def stage_previous(self, cr, uid, ids, context=None): """This function computes previous stage for case from its current stage using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') for case in self.browse(cr, uid, ids, context): prev_stage = False data = {} domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) stages = stage_pool.search(cr, uid, domain, order='sequence') index = 0 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) if index == 0: return False else: prev_stage = stages[index - 1] current_seq = case.stage_id.sequence if prev_stage: stage = stage_pool.browse(cr, uid, prev_stage, context=context) prev_seq = stage.sequence if current_seq and (prev_seq - current_seq) <= 1: data = {'stage_id': prev_stage} if stage.on_change: data.update({'probability': stage.probability}) self.write(cr, uid, [case.id], data, context=context) return prev_stage
468,092
def onchange_product_id(self, cr, uid, ids, product_id, name, context={}): """ Changes UoM and name if product_id changes. @param name: Name of the field @param product_id: Changed product_id @return: Dictionary of changed values """ if product_id: prod = self.pool.get('product.product').browse(cr, uid, [product_id])[0] v = {'product_uom': prod.uom_id.id} if not name: v['name'] = prod.name return {'value': v} return {}
def onchange_product_id(self, cr, uid, ids, product_id, name, context={}): """ Changes UoM and name if product_id changes. @param name: Name of the field @param product_id: Changed product_id @return: Dictionary of changed values """ if product_id: prod = self.pool.get('product.product').browse(cr, uid, [product_id])[0] v = {'product_uom': prod.uom_id.id} if not name: v['name'] = prod.name return {'value': v} return {}
468,093
def load_test(cr, module_name, id_map, mode): cr.commit() if not tools.config.options['test_disable']: try: _load_data(cr, module_name, id_map, mode, 'test') except Exception, e: logging.getLogger('test').exception('Tests failed to execute in %s module %s', module_name) finally: if tools.config.options['test_commit']: cr.commit() else: cr.rollback()
def load_test(cr, module_name, id_map, mode): cr.commit() if not tools.config.options['test_disable']: try: _load_data(cr, module_name, id_map, mode, 'test') except Exception, e: logging.getLogger('test').exception('Tests failed to execute in module %s', module_name) finally: if tools.config.options['test_commit']: cr.commit() else: cr.rollback()
468,094
f_pg_def = res[0]
f_pg_def = res[0]
468,095
def create(self, cr, user, vals, context=None): if ('name' not in vals) or (vals.get('name')=='/'): seq_obj_name = 'stock.picking.' + vals['type'] vals['name'] = self.pool.get('ir.sequence').get(cr, user, seq_obj_name) type_list = { 'out':_('Packing List'), 'in':_('Reception'), 'internal': _('Internal picking'), 'delivery': _('Delivery order') } new_id = super(stock_picking, self).create(cr, user, vals, context) if not vals.get('auto_picking', False): message = type_list.get(vals.get('type', False), _('Picking')) + " '" + (vals['name'] or "n/a") + _(" with origin")+" '" + (vals['origin'] or "n/a") + "' "+ _("is created.") self.log(cr, user, new_id, message) return new_id
def create(self, cr, user, vals, context=None): if ('name' not in vals) or (vals.get('name')=='/'): seq_obj_name = 'stock.picking.' + vals['type'] vals['name'] = self.pool.get('ir.sequence').get(cr, user, seq_obj_name) type_list = { 'out':_('Packing List'), 'in':_('Reception'), 'internal': _('Internal picking'), 'delivery': _('Delivery order') } new_id = super(stock_picking, self).create(cr, user, vals, context) if not vals.get('auto_picking', False): message = type_list.get(vals.get('type', False), _('Picking')) + " '" + (vals.get('name', 'n/a')) + _(" with origin")+" '" + vals.get('origin', 'n/a') + "' "+ _("is created.") self.log(cr, user, new_id, message) return new_id
468,096
def onchange_planned(self, cr, uid, ids, project, user_id=False, planned=0.0, effective=0.0, date_start=None, occupation_rate=0.0): result = {} if date_start: resource_pool = self.pool.get('resource.resource') project_pool = self.pool.get('project.project') resource_calendar = self.pool.get('resource.calendar') dt_start = mx.DateTime.strptime(date_start, '%Y-%m-%d %H:%M:%S') resource_id = resource_pool.search(cr, uid, [('user_id','=',user_id)]) if resource_id: resource_obj = resource_pool.browse(cr, uid, resource_id)[0] hrs = planned / (float(occupation_rate) * resource_obj.time_efficiency) calendar_id = resource_obj.calendar_id.id else: hrs = float(planned / occupation_rate) calendar_id = project_pool.browse(cr, uid, project).resource_calendar_id .id work_times = resource_calendar.interval_get(cr, uid, calendar_id or False, dt_start, hrs or 0.0, resource_id or False) result['date_end'] = work_times[-1][1].strftime('%Y-%m-%d %H:%M:%S') result['remaining_hours'] = planned - effective return {'value' : result}
def onchange_planned(self, cr, uid, ids, project, user_id=False, planned=0.0, effective=0.0, date_start=None, occupation_rate=0.0): result = {} if date_start: resource_pool = self.pool.get('resource.resource') project_pool = self.pool.get('project.project') resource_calendar = self.pool.get('resource.calendar') dt_start = mx.DateTime.strptime(date_start, '%Y-%m-%d %H:%M:%S') resource_id = resource_pool.search(cr, uid, [('user_id','=',user_id)]) if resource_id: resource_obj = resource_pool.browse(cr, uid, resource_id)[0] hrs = planned / (float(occupation_rate) * resource_obj.time_efficiency) calendar_id = resource_obj.calendar_id.id else: hrs = float(planned / float(occupation_rate)) calendar_id = project_pool.browse(cr, uid, project).resource_calendar_id .id work_times = resource_calendar.interval_get(cr, uid, calendar_id or False, dt_start, hrs or 0.0, resource_id or False) result['date_end'] = work_times[-1][1].strftime('%Y-%m-%d %H:%M:%S') result['remaining_hours'] = planned - effective return {'value' : result}
468,097
def __init__(self, cr, uid, name, context=None): if context is None: context = {} super(journal_print, self).__init__(cr, uid, name, context=context) self.period_ids = [] self.journal_ids = [] self.localcontext.update( { 'time': time, 'lines': self.lines, 'periods': self.periods, 'sum_debit_period': self._sum_debit_period, 'sum_credit_period': self._sum_credit_period, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_start_date': self.get_start_date, 'get_end_date': self.get_end_date, 'get_filter': self._get_filter })
def __init__(self, cr, uid, name, context=None): if context is None: context = {} super(journal_print, self).__init__(cr, uid, name, context=context) self.period_ids = [] self.journal_ids = [] self.localcontext.update( { 'time': time, 'lines': self.lines, 'periods': self.periods, 'sum_debit_period': self._sum_debit_period, 'sum_credit_period': self._sum_credit_period, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_start_date': self._get_start_date, 'get_end_date': self._get_end_date, 'get_filter': self._get_filter })
468,098
def mass_mail_send(self, cr, uid, ids, context): """ Send Email
def mass_mail_send(self, cr, uid, ids, context): """ Send Email
468,099