diff --git a/addons/account/report/account_partner_balance.py b/addons/account/report/account_partner_balance.py
index ab1c6f656f2..ab3cfd70970 100644
--- a/addons/account/report/account_partner_balance.py
+++ b/addons/account/report/account_partner_balance.py
@@ -79,7 +79,6 @@ class partner_balance(report_sxw.rml_parse, common_report_header):
move_state = ['posted']
full_account = []
- result_tmp = 0.0
self.cr.execute(
"SELECT p.ref,l.account_id,ac.name AS account_name,ac.code AS code,p.name, sum(debit) AS debit, sum(credit) AS credit, " \
"CASE WHEN sum(debit) > sum(credit) " \
diff --git a/addons/account/report/account_profit_loss.py b/addons/account/report/account_profit_loss.py
index 9469c3e0d7e..0bfaea7a570 100644
--- a/addons/account/report/account_profit_loss.py
+++ b/addons/account/report/account_profit_loss.py
@@ -77,7 +77,6 @@ class report_pl_account_horizontal(rml_parse.rml_parse, common_report_header):
db_pool = pooler.get_pool(self.cr.dbname)
account_pool = db_pool.get('account.account')
- year_pool = db_pool.get('account.fiscalyear')
types = [
'expense',
diff --git a/addons/account/report/account_tax_code.py b/addons/account/report/account_tax_code.py
index e59839f8267..42bbe305381 100644
--- a/addons/account/report/account_tax_code.py
+++ b/addons/account/report/account_tax_code.py
@@ -21,9 +21,9 @@
##############################################################################
import time
+
import rml_parse
from report import report_sxw
-import re
def _get_country(record):
if record.partner_id \
diff --git a/addons/account/report/rml_parse.py b/addons/account/report/rml_parse.py
index c71c0254849..aab5e14c777 100644
--- a/addons/account/report/rml_parse.py
+++ b/addons/account/report/rml_parse.py
@@ -19,7 +19,6 @@
#
##############################################################################
-import time
import re
import sys
@@ -55,15 +54,15 @@ class rml_parse(report_sxw.rml_parse):
ellipsis = ellipsis or ''
try:
return string[:maxlen - len(ellipsis) ] + (ellipsis, '')[len(string) < maxlen]
- except Exception, e:
+ except:
return False
def _strip_name(self, name, maxlen=50):
return self._ellipsis(name, maxlen, '...')
- def _get_and_change_date_format_for_swiss (self,date_to_format):
+ def _get_and_change_date_format_for_swiss(self,date_to_format):
date_formatted=''
if date_to_format:
- date_formatted = strptime (date_to_format,'%Y-%m-%d').strftime('%d.%m.%Y')
+ date_formatted = strptime(date_to_format,'%Y-%m-%d').strftime('%d.%m.%Y')
return date_formatted
def _explode_name(self,chaine,length):
@@ -109,15 +108,14 @@ class rml_parse(report_sxw.rml_parse):
i = i + length
chaine = str("".join(ast))
return chaine
- def repair_string(self,chaine):
+ def repair_string(self, chaine):
ast = list(chaine)
UnicodeAst = []
- _previouslyfound = False
i = 0
while i < len(ast):
elem = ast[i]
try:
- Stringer = elem.encode("utf-8")
+ elem.encode("utf-8")
except UnicodeDecodeError:
to_reencode = elem + ast[i+1]
print str(to_reencode)
diff --git a/addons/account_analytic_analysis/account_analytic_analysis.py b/addons/account_analytic_analysis/account_analytic_analysis.py
index b1b4ece2f64..90fc9f1fd6a 100644
--- a/addons/account_analytic_analysis/account_analytic_analysis.py
+++ b/addons/account_analytic_analysis/account_analytic_analysis.py
@@ -250,33 +250,56 @@ class account_analytic_account(osv.osv):
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None):
res = {}
- parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context))
- if parent_ids:
- cr.execute("SELECT account_analytic_line.account_id, COALESCE(SUM(amount_currency), 0.0) \
+ res_final = {}
+ child_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context))
+ for i in child_ids:
+ res[i] = {}
+ for n in [name]:
+ res[i][n] = 0.0
+ if not child_ids:
+ return res
+
+ if child_ids:
+ cr.execute("SELECT account_analytic_line.account_id, COALESCE(SUM(amount), 0.0) \
FROM account_analytic_line \
JOIN account_analytic_journal \
ON account_analytic_line.journal_id = account_analytic_journal.id \
WHERE account_analytic_line.account_id IN %s \
AND account_analytic_journal.type = 'sale' \
- GROUP BY account_analytic_line.account_id", (parent_ids,))
+ GROUP BY account_analytic_line.account_id", (child_ids,))
for account_id, sum in cr.fetchall():
- res[account_id] = round(sum,2)
- return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context=context)
+ res[account_id][name] = round(sum,2)
+ data = self._compute_level_tree(cr, uid, ids, child_ids, res, [name], context)
+ for i in data:
+ res_final[i] = data[i][name]
+ return res_final
def _total_cost_calc(self, cr, uid, ids, name, arg, context=None):
res = {}
- parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context))
- if parent_ids:
- cr.execute("""SELECT account_analytic_line.account_id, COALESCE(SUM(amount_currency), 0.0) \
+ res_final = {}
+ child_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context))
+
+ for i in child_ids:
+ res[i] = {}
+ for n in [name]:
+ res[i][n] = 0.0
+ if not child_ids:
+ return res
+
+ if child_ids:
+ cr.execute("""SELECT account_analytic_line.account_id, COALESCE(SUM(amount), 0.0) \
FROM account_analytic_line \
JOIN account_analytic_journal \
ON account_analytic_line.journal_id = account_analytic_journal.id \
WHERE account_analytic_line.account_id IN %s \
AND amount<0 \
- GROUP BY account_analytic_line.account_id""",(parent_ids,))
+ GROUP BY account_analytic_line.account_id""",(child_ids,))
for account_id, sum in cr.fetchall():
- res[account_id] = round(sum,2)
- return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context=context)
+ res[account_id][name] = round(sum,2)
+ data = self._compute_level_tree(cr, uid, ids, child_ids, res, [name], context)
+ for i in data:
+ res_final[i] = data[i][name]
+ return res_final
def _remaining_hours_calc(self, cr, uid, ids, name, arg, context=None):
res = {}
diff --git a/addons/account_voucher/__init__.py b/addons/account_voucher/__init__.py
index 2b1478d9fa0..9796f81d5e5 100644
--- a/addons/account_voucher/__init__.py
+++ b/addons/account_voucher/__init__.py
@@ -24,4 +24,4 @@ import invoice
import report
import wizard
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py
index 9dca6fdd9c6..a07e41ff000 100644
--- a/addons/account_voucher/account_voucher.py
+++ b/addons/account_voucher/account_voucher.py
@@ -573,6 +573,7 @@ class account_voucher(osv.osv):
move_line_pool = self.pool.get('account.move.line')
currency_pool = self.pool.get('res.currency')
tax_obj = self.pool.get('account.tax')
+ seq_obj = self.pool.get('ir.sequence')
for inv in self.browse(cr, uid, ids):
if not inv.line_ids:
raise osv.except_osv(_('No Lines !'), _('Please create some lines'))
@@ -581,7 +582,7 @@ class account_voucher(osv.osv):
if inv.number:
name = inv.number
elif inv.journal_id.sequence_id:
- name = self.pool.get('ir.sequence').get_id(cr, uid, inv.journal_id.sequence_id.id)
+ name = seq_obj.get_id(cr, uid, inv.journal_id.sequence_id.id)
else:
raise osv.except_osv(_('Error !'), _('Please define a sequence on the journal !'))
if not inv.reference:
@@ -687,7 +688,7 @@ class account_voucher(osv.osv):
rec_ids = [master_line, line.move_line_id.id]
rec_list_ids.append(rec_ids)
- if not self.pool.get('res.currency').is_zero(cr, uid, inv.currency_id, line_total):
+ if not currency_pool.is_zero(cr, uid, inv.currency_id, line_total):
diff = line_total
move_line = {
'name': name,
@@ -854,17 +855,19 @@ class account_bank_statement(osv.osv):
_inherit = 'account.bank.statement'
def button_cancel(self, cr, uid, ids, context=None):
+ voucher_obj = self.pool.get('account.voucher')
for st in self.browse(cr, uid, ids, context):
voucher_ids = []
for line in st.line_ids:
if line.voucher_id:
voucher_ids.append(line.voucher_id.id)
- self.pool.get('account.voucher').cancel_voucher(cr, uid, voucher_ids, context)
+ voucher_obj.cancel_voucher(cr, uid, voucher_ids, context)
return super(account_bank_statement, self).button_cancel(cr, uid, ids, context=context)
def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, next_number, context=None):
voucher_obj = self.pool.get('account.voucher')
wf_service = netsvc.LocalService("workflow")
+ move_line_obj = self.pool.get('account.move.line')
bank_st_line_obj = self.pool.get('account.bank.statement.line')
st_line = bank_st_line_obj.browse(cr, uid, st_line_id, context=context)
if st_line.voucher_id:
@@ -878,7 +881,7 @@ class account_bank_statement(osv.osv):
'move_ids': [(4, v.move_id.id, False)]
})
- return self.pool.get('account.move.line').write(cr, uid, [x.id for x in v.move_ids], {'statement_id': st_line.statement_id.id}, context=context)
+ return move_line_obj.write(cr, uid, [x.id for x in v.move_ids], {'statement_id': st_line.statement_id.id}, context=context)
return super(account_bank_statement, self).create_move_from_st_line(cr, uid, st_line.id, company_currency_id, next_number, context=context)
account_bank_statement()
@@ -912,14 +915,15 @@ class account_bank_statement_line(osv.osv):
}
def unlink(self, cr, uid, ids, context=None):
+ voucher_obj = self.pool.get('account.voucher')
statement_line = self.browse(cr, uid, ids, context)
unlink_ids = []
for st_line in statement_line:
if st_line.voucher_id:
unlink_ids.append(st_line.voucher_id.id)
- self.pool.get('account.voucher').unlink(cr, uid, unlink_ids, context=context)
+ voucher_obj.unlink(cr, uid, unlink_ids, context=context)
return super(account_bank_statement_line, self).unlink(cr, uid, ids, context=context)
account_bank_statement_line()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:=======
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/account_voucher/report/account_voucher.py b/addons/account_voucher/report/account_voucher.py
index 7931daffbac..e44adee974e 100644
--- a/addons/account_voucher/report/account_voucher.py
+++ b/addons/account_voucher/report/account_voucher.py
@@ -32,7 +32,7 @@ class report_voucher(report_sxw.rml_parse):
'get_title': self.get_title,
'debit':self.debit,
'credit':self.credit,
- 'get_ref' : self._get_ref
+ 'get_ref': self._get_ref
})
def convert(self, amount, cur):
@@ -58,9 +58,10 @@ class report_voucher(report_sxw.rml_parse):
return credit
def _get_ref(self, voucher_id, move_ids):
- voucher_line = self.pool.get('account.voucher.line').search(self.cr, self.uid, [('partner_id', '=', move_ids.partner_id.id), ('voucher_id', '=', voucher_id)])
+ voucher_line_obj = self.pool.get('account.voucher.line')
+ voucher_line = voucher_line_obj.search(self.cr, self.uid, [('partner_id', '=', move_ids.partner_id.id), ('voucher_id', '=', voucher_id)])
if voucher_line:
- voucher = self.pool.get('account.voucher.line').browse(self.cr, self.uid, voucher_line)[0]
+ voucher = voucher_line_obj.browse(self.cr, self.uid, voucher_line)[0]
return voucher.name
else:
return
diff --git a/addons/account_voucher/wizard/account_statement_from_invoice.py b/addons/account_voucher/wizard/account_statement_from_invoice.py
index 507fdcabffa..b4671ae208a 100644
--- a/addons/account_voucher/wizard/account_statement_from_invoice.py
+++ b/addons/account_voucher/wizard/account_statement_from_invoice.py
@@ -18,6 +18,7 @@
# along with this program. If not, see .
#
##############################################################################
+
import time
from osv import fields, osv
diff --git a/addons/account_voucher/wizard/account_voucher_unreconcile.py b/addons/account_voucher/wizard/account_voucher_unreconcile.py
index 71b4fbc8fb5..69aa6e1181d 100644
--- a/addons/account_voucher/wizard/account_voucher_unreconcile.py
+++ b/addons/account_voucher/wizard/account_voucher_unreconcile.py
@@ -25,15 +25,15 @@ from osv import fields
class account_voucher_unreconcile(osv.osv_memory):
_name = "account.voucher.unreconcile"
_description = "Account voucher unreconcile"
-
+
_columns = {
'remove':fields.boolean('Want to remove accounting entries too ?', required=False),
}
-
+
_defaults = {
'remove': True,
}
-
+
def trans_unrec(self, cr, uid, ids, context=None):
# res = self.browse(cr, uid, ids[0])
if context is None:
@@ -54,9 +54,9 @@ class account_voucher_unreconcile(osv.osv_memory):
voucher_pool.cancel_voucher(cr, uid, [context.get('active_id')], context)
# wf_service = netsvc.LocalService("workflow")
# wf_service.trg_validate(uid, 'account.voucher', context.get('active_id'), 'cancel_voucher', cr)
-
+
return {}
account_voucher_unreconcile()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py
index 4e53a895587..1189e1c4cec 100644
--- a/addons/email_template/email_template.py
+++ b/addons/email_template/email_template.py
@@ -103,7 +103,7 @@ def get_value(cursor, user, recid, message=None, template=None, context=None):
class email_template(osv.osv):
"Templates for sending Email"
-
+
_name = "email.template"
_description = 'Email Templates for Models'
@@ -131,7 +131,7 @@ class email_template(osv.osv):
'def_to':fields.char(
'Recipient (To)',
size=250,
- help="The Recipient of email. "
+ help="The Recipient of email. "
"Placeholders can be used here. "
"e.g. ${object.email_to}"),
'def_cc':fields.char(
@@ -146,20 +146,20 @@ class email_template(osv.osv):
help="Blind Carbon Copy address(es), comma-separated."
" Placeholders can be used here. "
"e.g. ${object.email_bcc}"),
- 'reply_to':fields.char('Reply-To',
- size=250,
+ 'reply_to':fields.char('Reply-To',
+ size=250,
help="The address recipients should reply to,"
" if different from the From address."
" Placeholders can be used here. "
"e.g. ${object.email_reply_to}"),
- 'message_id':fields.char('Message-ID',
- size=250,
+ 'message_id':fields.char('Message-ID',
+ size=250,
help="Specify the Message-ID SMTP header to use in outgoing emails. Please note that this overrides the Resource tracking option! Placeholders can be used here."),
'track_campaign_item':fields.boolean('Resource Tracking',
help="Enable this is you wish to include a special \
tracking marker in outgoing emails so you can identify replies and link \
them back to the corresponding resource record. \
-This is useful for CRM leads for example"),
+This is useful for CRM leads for example"),
'lang':fields.char(
'Language',
size=250,
@@ -182,7 +182,7 @@ This is useful for CRM leads for example"),
translate=True),
'use_sign':fields.boolean(
'Signature',
- help="the signature from the User details"
+ help="the signature from the User details"
" will be appended to the mail"),
'file_name':fields.char(
'Report Filename',
@@ -199,16 +199,16 @@ This is useful for CRM leads for example"),
'attachment_id',
'Attached Files',
help="You may attach existing files to this template, "
- "so they will be added in all emails created from this template"),
+ "so they will be added in all emails created from this template"),
'ref_ir_act_window':fields.many2one(
'ir.actions.act_window',
'Window Action',
- help="Action that will open this email template on Resource records",
+ help="Action that will open this email template on Resource records",
readonly=True),
'ref_ir_value':fields.many2one(
'ir.values',
'Wizard Button',
- help="Button in the side bar of the form view of this Resource that will invoke the Window Action",
+ help="Button in the side bar of the form view of this Resource that will invoke the Window Action",
readonly=True),
'allowed_groups':fields.many2many(
'res.groups',
@@ -265,7 +265,7 @@ This is useful for CRM leads for example"),
'template_language' : lambda *a:'mako',
}
-
+
_sql_constraints = [
('name', 'unique (name)', _('The template name must be unique !'))
]
@@ -312,11 +312,11 @@ This is useful for CRM leads for example"),
def delete_action(self, cr, uid, ids, context):
self.unlink_action(cr, uid, ids, context)
return True
-
+
def unlink(self, cr, uid, ids, context=None):
self.unlink_action(cr, uid, ids, context)
return super(email_template, self).unlink(cr, uid, ids, context)
-
+
def copy(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
@@ -328,7 +328,7 @@ This is useful for CRM leads for example"),
new_name = new_name + '_' + random.choice('abcdefghij') + random.choice('lmnopqrs') + random.choice('tuvwzyz')
default.update({'name':new_name})
return super(email_template, self).copy(cr, uid, id, default, context)
-
+
def build_expression(self, field_name, sub_field_name, null_value, template_language='mako'):
"""
Returns a template expression based on data provided
@@ -354,10 +354,10 @@ This is useful for CRM leads for example"),
if sub_field_name:
expression += "." + sub_field_name
if null_value:
- expression += "|default: '''%s'''" % null_value
+ expression += "|default: '''%s'''" % null_value
expression += "}}"
- return expression
-
+ return expression
+
def onchange_model_object_field(self, cr, uid, ids, model_object_field, template_language, context=None):
if not model_object_field:
return {}
@@ -385,7 +385,7 @@ This is useful for CRM leads for example"),
result['sub_model_object_field'] = False
result['null_value'] = False
return {'value':result}
-
+
def onchange_sub_model_object_field(self, cr, uid, ids, model_object_field, sub_model_object_field, template_language, context=None):
if not model_object_field or not sub_model_object_field:
return {}
@@ -447,7 +447,7 @@ This is useful for CRM leads for example"),
def _add_attachment(self, cursor, user, mailbox_id, name, data, filename, context=None):
"""
Add an attachment to a given mailbox entry.
-
+
:param data: base64 encoded attachment data to store
"""
attachment_obj = self.pool.get('ir.attachment')
@@ -484,7 +484,7 @@ This is useful for CRM leads for example"),
"""
Generate report to be attached and attach it
to the email, and add any directly attached files as well.
-
+
@param cursor: Database Cursor
@param user: ID of User
@param template: Browse record of
@@ -492,8 +492,8 @@ This is useful for CRM leads for example"),
@param record_id: ID of the target model
for which this mail has
to be generated
- @param mail: Browse record of email object
- @return: True
+ @param mail: Browse record of email object
+ @return: True
"""
if template.report_template:
reportname = 'report.' + \
@@ -510,7 +510,7 @@ This is useful for CRM leads for example"),
user,
[record_id],
data,
- context)
+ context)
fname = tools.ustr(get_value(cursor, user, record_id,
template.file_name, template, context)
or 'Report')
@@ -524,7 +524,7 @@ This is useful for CRM leads for example"),
self._add_attachment(cursor, user, mail.id, attachment.name, attachment.datas, attachment.datas_fname, context)
return True
-
+
def _generate_mailbox_item_from_template(self,
cursor,
user,
@@ -534,7 +534,7 @@ This is useful for CRM leads for example"),
"""
Generates an email from the template for
record record_id of target object
-
+
@param cursor: Database Cursor
@param user: ID of User
@param template: Browse record of
@@ -542,7 +542,7 @@ This is useful for CRM leads for example"),
@param record_id: ID of the target model
for which this mail has
to be generated
- @return: ID of created object
+ @return: ID of created object
"""
if context is None:
context = {}
@@ -571,9 +571,9 @@ This is useful for CRM leads for example"),
ctx = context.copy()
ctx.update({'lang':lang})
template = self.browse(cursor, user, template.id, context=ctx)
-
- # determine name of sender, either it is specified in email_id or we
- # use the account name
+
+ # determine name of sender, either it is specified in email_id or we
+ # use the account name
email_id = from_account['email_id'].strip()
email_from = re.findall(r'([^ ,<@]+@[^> ,]+)', email_id)[0]
if email_from != email_id:
@@ -663,7 +663,7 @@ This is useful for CRM leads for example"),
context)
return mailbox_id
-
+
def generate_mail(self,
cursor,
@@ -721,7 +721,7 @@ email_template()
class email_template_preview(osv.osv_memory):
_name = "email_template.preview"
_description = "Email Template Preview"
-
+
def _get_model_recs(self, cr, uid, context=None):
if context is None:
context = {}
@@ -738,6 +738,7 @@ class email_template_preview(osv.osv_memory):
if default_id and default_id not in ref_obj_ids:
ref_obj_ids.insert(0, default_id)
return model_obj.name_get(cr, uid, ref_obj_ids, context)
+ return []
def default_get(self, cr, uid, fields, context=None):
if context is None:
@@ -762,7 +763,7 @@ class email_template_preview(osv.osv_memory):
context['template_id'],
['object_name'],
context)['object_name']
-
+
_columns = {
'ref_template':fields.many2one(
'email.template',
@@ -772,13 +773,13 @@ class email_template_preview(osv.osv_memory):
'to':fields.char('To', size=250, readonly=True),
'cc':fields.char('CC', size=250, readonly=True),
'bcc':fields.char('BCC', size=250, readonly=True),
- 'reply_to':fields.char('Reply-To',
- size=250,
+ 'reply_to':fields.char('Reply-To',
+ size=250,
help="The address recipients should reply to,"
" if different from the From address."
" Placeholders can be used here."),
- 'message_id':fields.char('Message-ID',
- size=250,
+ 'message_id':fields.char('Message-ID',
+ size=250,
help="The Message-ID header value, if you need to"
"specify it, for example to automatically recognize the replies later."
" Placeholders can be used here."),
@@ -819,7 +820,7 @@ class email_template_preview(osv.osv_memory):
vals['body_html'] = get_value(cr, uid, rel_model_ref, template.def_body_html, template, context)
vals['report'] = get_value(cr, uid, rel_model_ref, template.file_name, template, context)
return {'value':vals}
-
+
email_template_preview()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/event/event.py b/addons/event/event.py
index 61a24901b0a..e8c60660136 100644
--- a/addons/event/event.py
+++ b/addons/event/event.py
@@ -55,7 +55,8 @@ class event_event(osv.osv):
'registration_ids': False,
})
return super(event_event, self).copy(cr, uid, id, default=default, context=context)
- def onchange_product(self, cr, uid, ids, product_id):
+
+ def onchange_product(self, cr, uid, ids, product_id=False):
"""This function returns value of product's unit price based on product id.
@param self: The object pointer
@param cr: the current row, from the database cursor,
@@ -132,7 +133,6 @@ class event_event(osv.osv):
}
return res
-
def _get_register(self, cr, uid, ids, fields, args, context=None):
"""Get Confirm or uncofirm register value.
@param ids: List of Event registration type's id
@@ -165,7 +165,6 @@ class event_event(osv.osv):
res[event.id]['register_current'] = number and number[0] or 0.0
if 'register_prospect' in fields:
res[event.id]['register_prospect'] = number and number[0] or 0.0
-
return res
def write(self, cr, uid, ids, vals, context=None):
@@ -707,7 +706,7 @@ class event_registration_badge(osv.osv):
_name = 'event.registration.badge'
_description = __doc__
_columns = {
- 'registration_id': fields.many2one('event.registration', 'Registration', required=True),
+ "registration_id": fields.many2one('event.registration', 'Registration', required=True),
"title": fields.char('Title', size=128),
"name": fields.char('Name', size=128, required=True),
"address_id": fields.many2one('res.partner.address', 'Address'),
diff --git a/addons/membership/demo_data.xml b/addons/membership/demo_data.xml
deleted file mode 100644
index 6809702a113..00000000000
--- a/addons/membership/demo_data.xml
+++ /dev/null
@@ -1,166 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/addons/membership/membership.py b/addons/membership/membership.py
index 12a36fb7e8a..a7f84603608 100644
--- a/addons/membership/membership.py
+++ b/addons/membership/membership.py
@@ -484,6 +484,7 @@ class Product(osv.osv):
_defaults = {
'membership': False,
}
+
Product()
@@ -501,6 +502,7 @@ class Invoice(osv.osv):
[l.id for l in invoice.invoice_line])])
member_line_obj.write(cr, uid, mlines, {'date_cancel': today})
return super(Invoice, self).action_cancel(cr, uid, ids)
+
Invoice()
class account_invoice_line(osv.osv):
@@ -573,4 +575,5 @@ class account_invoice_line(osv.osv):
return result
account_invoice_line()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/membership/report/report_membership.py b/addons/membership/report/report_membership.py
index 34ca21e0e9c..43ffa7a5b28 100644
--- a/addons/membership/report/report_membership.py
+++ b/addons/membership/report/report_membership.py
@@ -23,7 +23,6 @@ from osv import fields, osv
import tools
import decimal_precision as dp
-
STATE = [
('none', 'Non Member'),
('canceled', 'Cancelled Member'),
@@ -63,7 +62,7 @@ class report_membership(osv.osv):
'membership_state': fields.selection(STATE, 'Current Membership State', readonly=True),
'user_id': fields.many2one('res.users', 'Salesman', readonly=True),
'company_id': fields.many2one('res.company', 'Company', readonly=True)
-}
+ }
def init(self, cr):
'''Create the view'''
@@ -127,20 +126,20 @@ class report_membership(osv.osv):
ml.state,
ml.id
) AS foo
- GROUP BY
- year,
- month,
- date_from,
- date_to,
- partner_id,
- user_id,
- membership_id,
- company_id,
- membership_state,
- associate_member_id,
+ GROUP BY
+ year,
+ month,
+ date_from,
+ date_to,
+ partner_id,
+ user_id,
+ membership_id,
+ company_id,
+ membership_state,
+ associate_member_id,
membership_amount
)""")
report_membership()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/membership/wizard/membership_invoice.py b/addons/membership/wizard/membership_invoice.py
index 9b9fddc2313..b0a46f3951d 100644
--- a/addons/membership/wizard/membership_invoice.py
+++ b/addons/membership/wizard/membership_invoice.py
@@ -19,11 +19,7 @@
#
##############################################################################
-import time
-
from osv import fields, osv
-from tools.translate import _
-import tools
import decimal_precision as dp
class membership_invoice(osv.osv_memory):
@@ -35,7 +31,7 @@ class membership_invoice(osv.osv_memory):
'product_id': fields.many2one('product.product','Membership', required=True),
'member_price': fields.float('Member Price', digits_compute= dp.get_precision('Sale Price'), required=True),
}
- def onchange_product(self, cr, uid, ids, product_id):
+ def onchange_product(self, cr, uid, ids, product_id=False):
"""This function returns value of product's member price based on product id.
"""
if not product_id:
@@ -49,15 +45,14 @@ class membership_invoice(osv.osv_memory):
datas = {}
if not context:
context = {}
- data = self.browse(cr, uid, ids)
+ data = self.browse(cr, uid, ids, context=context)
if data:
data = data[0]
datas = {
'membership_product_id': data.product_id.id,
'amount': data.member_price
}
- invoice_ids = context.get('active_ids', [])
- invoice_list = partner_obj.create_membership_invoice(cr, uid, invoice_ids, datas=datas, context=context)
+ invoice_list = partner_obj.create_membership_invoice(cr, uid, context.get('active_ids', []), datas=datas, context=context)
return {
'domain': [('id', 'in', invoice_list)],
@@ -70,4 +65,4 @@ class membership_invoice(osv.osv_memory):
membership_invoice()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/partner_geo_assign/i18n/de.po b/addons/partner_geo_assign/i18n/de.po
deleted file mode 100644
index 86d223a36ba..00000000000
--- a/addons/partner_geo_assign/i18n/de.po
+++ /dev/null
@@ -1,117 +0,0 @@
-# German translation for openobject-addons
-# Copyright (c) 2010 Rosetta Contributors and Canonical Ltd 2010
-# This file is distributed under the same license as the openobject-addons package.
-# FIRST AUTHOR , 2010.
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: openobject-addons\n"
-"Report-Msgid-Bugs-To: FULL NAME \n"
-"POT-Creation-Date: 2010-08-20 08:40+0000\n"
-"PO-Revision-Date: 2010-10-05 13:33+0000\n"
-"Last-Translator: FULL NAME \n"
-"Language-Team: German \n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"X-Launchpad-Export-Date: 2010-10-08 04:39+0000\n"
-"X-Generator: Launchpad (build Unknown)\n"
-
-#. module: partner_geo_assign
-#: code:addons/partner_geo_assign/partner_geo_assign.py:0
-#, python-format
-msgid "Network error"
-msgstr ""
-
-#. module: partner_geo_assign
-#: constraint:ir.ui.view:0
-msgid "Invalid XML for View Architecture!"
-msgstr ""
-
-#. module: partner_geo_assign
-#: help:res.partner,partner_weight:0
-msgid ""
-"Gives the probability to assign a lead to this partner. (0 means no "
-"assignation.)"
-msgstr ""
-
-#. module: partner_geo_assign
-#: model:ir.module.module,description:partner_geo_assign.module_meta_information
-msgid ""
-"\n"
-"This is the module used by OpenERP SA to redirect customers to his "
-"partners,\n"
-"based on geolocalization.\n"
-" "
-msgstr ""
-
-#. module: partner_geo_assign
-#: field:res.partner,partner_weight:0
-msgid "Weight"
-msgstr ""
-
-#. module: partner_geo_assign
-#: model:ir.module.module,shortdesc:partner_geo_assign.module_meta_information
-msgid "Partner Geo-Localisation"
-msgstr ""
-
-#. module: partner_geo_assign
-#: view:res.partner:0
-msgid "Geo Localization"
-msgstr ""
-
-#. module: partner_geo_assign
-#: code:addons/partner_geo_assign/partner_geo_assign.py:0
-#, python-format
-msgid ""
-"Could not contact geolocation servers, please make sure you have a working "
-"internet connection (%s)"
-msgstr ""
-
-#. module: partner_geo_assign
-#: constraint:ir.model:0
-msgid ""
-"The Object name must start with x_ and not contain any special character !"
-msgstr ""
-
-#. module: partner_geo_assign
-#: field:res.partner,date_localization:0
-msgid "Geo Localization Date"
-msgstr ""
-
-#. module: partner_geo_assign
-#: view:crm.lead:0
-msgid "Geo Assign"
-msgstr ""
-
-#. module: partner_geo_assign
-#: field:crm.lead,partner_latitude:0
-#: field:res.partner,partner_latitude:0
-msgid "Geo Latitude"
-msgstr ""
-
-#. module: partner_geo_assign
-#: model:ir.model,name:partner_geo_assign.model_crm_lead
-msgid "crm.lead"
-msgstr ""
-
-#. module: partner_geo_assign
-#: model:ir.model,name:partner_geo_assign.model_res_partner
-msgid "Partner"
-msgstr ""
-
-#. module: partner_geo_assign
-#: view:crm.lead:0
-msgid "Geo Assignation"
-msgstr ""
-
-#. module: partner_geo_assign
-#: view:res.partner:0
-msgid "Geo Localize"
-msgstr ""
-
-#. module: partner_geo_assign
-#: field:crm.lead,partner_longitude:0
-#: field:res.partner,partner_longitude:0
-msgid "Geo Longitude"
-msgstr ""
diff --git a/addons/partner_geo_assign/i18n/fr.po b/addons/partner_geo_assign/i18n/fr.po
deleted file mode 100644
index 093542f4993..00000000000
--- a/addons/partner_geo_assign/i18n/fr.po
+++ /dev/null
@@ -1,116 +0,0 @@
-# Translation of OpenERP Server.
-# This file contains the translation of the following modules:
-# * partner_geo_assign
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: OpenERP Server 6.0dev\n"
-"Report-Msgid-Bugs-To: support@openerp.com\n"
-"POT-Creation-Date: 2010-08-20 08:40+0000\n"
-"PO-Revision-Date: 2010-08-30 12:19+0000\n"
-"Last-Translator: <>\n"
-"Language-Team: \n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"X-Launchpad-Export-Date: 2010-09-29 05:17+0000\n"
-"X-Generator: Launchpad (build Unknown)\n"
-
-#. module: partner_geo_assign
-#: code:addons/partner_geo_assign/partner_geo_assign.py:0
-#, python-format
-msgid "Network error"
-msgstr ""
-
-#. module: partner_geo_assign
-#: constraint:ir.ui.view:0
-msgid "Invalid XML for View Architecture!"
-msgstr ""
-
-#. module: partner_geo_assign
-#: help:res.partner,partner_weight:0
-msgid ""
-"Gives the probability to assign a lead to this partner. (0 means no "
-"assignation.)"
-msgstr ""
-
-#. module: partner_geo_assign
-#: model:ir.module.module,description:partner_geo_assign.module_meta_information
-msgid ""
-"\n"
-"This is the module used by OpenERP SA to redirect customers to his "
-"partners,\n"
-"based on geolocalization.\n"
-" "
-msgstr ""
-
-#. module: partner_geo_assign
-#: field:res.partner,partner_weight:0
-msgid "Weight"
-msgstr ""
-
-#. module: partner_geo_assign
-#: model:ir.module.module,shortdesc:partner_geo_assign.module_meta_information
-msgid "Partner Geo-Localisation"
-msgstr ""
-
-#. module: partner_geo_assign
-#: view:res.partner:0
-msgid "Geo Localization"
-msgstr ""
-
-#. module: partner_geo_assign
-#: code:addons/partner_geo_assign/partner_geo_assign.py:0
-#, python-format
-msgid ""
-"Could not contact geolocation servers, please make sure you have a working "
-"internet connection (%s)"
-msgstr ""
-
-#. module: partner_geo_assign
-#: constraint:ir.model:0
-msgid ""
-"The Object name must start with x_ and not contain any special character !"
-msgstr ""
-
-#. module: partner_geo_assign
-#: field:res.partner,date_localization:0
-msgid "Geo Localization Date"
-msgstr ""
-
-#. module: partner_geo_assign
-#: view:crm.lead:0
-msgid "Geo Assign"
-msgstr ""
-
-#. module: partner_geo_assign
-#: field:crm.lead,partner_latitude:0
-#: field:res.partner,partner_latitude:0
-msgid "Geo Latitude"
-msgstr ""
-
-#. module: partner_geo_assign
-#: model:ir.model,name:partner_geo_assign.model_crm_lead
-msgid "crm.lead"
-msgstr ""
-
-#. module: partner_geo_assign
-#: model:ir.model,name:partner_geo_assign.model_res_partner
-msgid "Partner"
-msgstr ""
-
-#. module: partner_geo_assign
-#: view:crm.lead:0
-msgid "Geo Assignation"
-msgstr ""
-
-#. module: partner_geo_assign
-#: view:res.partner:0
-msgid "Geo Localize"
-msgstr ""
-
-#. module: partner_geo_assign
-#: field:crm.lead,partner_longitude:0
-#: field:res.partner,partner_longitude:0
-msgid "Geo Longitude"
-msgstr ""
diff --git a/addons/partner_geo_assign/i18n/it.po b/addons/partner_geo_assign/i18n/it.po
deleted file mode 100644
index bcc5ac363a1..00000000000
--- a/addons/partner_geo_assign/i18n/it.po
+++ /dev/null
@@ -1,128 +0,0 @@
-# Italian translation for openobject-addons
-# Copyright (c) 2010 Rosetta Contributors and Canonical Ltd 2010
-# This file is distributed under the same license as the openobject-addons package.
-# FIRST AUTHOR , 2010.
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: openobject-addons\n"
-"Report-Msgid-Bugs-To: FULL NAME \n"
-"POT-Creation-Date: 2010-08-20 08:40+0000\n"
-"PO-Revision-Date: 2010-09-29 09:26+0000\n"
-"Last-Translator: OpenERP Administrators \n"
-"Language-Team: Italian \n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"X-Launchpad-Export-Date: 2010-09-30 04:44+0000\n"
-"X-Generator: Launchpad (build Unknown)\n"
-
-#. module: partner_geo_assign
-#: code:addons/partner_geo_assign/partner_geo_assign.py:0
-#, python-format
-msgid "Network error"
-msgstr "Errore di rete"
-
-#. module: partner_geo_assign
-#: constraint:ir.ui.view:0
-msgid "Invalid XML for View Architecture!"
-msgstr "XML non valido per Visualizzare l'architettura!"
-
-#. module: partner_geo_assign
-#: help:res.partner,partner_weight:0
-msgid ""
-"Gives the probability to assign a lead to this partner. (0 means no "
-"assignation.)"
-msgstr ""
-"Fornisce la probabilità di assegnare una richesta a questo partner (0 "
-"significa nessuna assegnazione)."
-
-#. module: partner_geo_assign
-#: model:ir.module.module,description:partner_geo_assign.module_meta_information
-msgid ""
-"\n"
-"This is the module used by OpenERP SA to redirect customers to his "
-"partners,\n"
-"based on geolocalization.\n"
-" "
-msgstr ""
-"\n"
-"Questo è il modulo usato da OpenERP SA per indirizzare i venditori ai loro "
-"partners,\n"
-"basandosi sulla geolocalizzazione.\n"
-" "
-
-#. module: partner_geo_assign
-#: field:res.partner,partner_weight:0
-msgid "Weight"
-msgstr "Peso"
-
-#. module: partner_geo_assign
-#: model:ir.module.module,shortdesc:partner_geo_assign.module_meta_information
-msgid "Partner Geo-Localisation"
-msgstr "Geo-Localizzazione Partner"
-
-#. module: partner_geo_assign
-#: view:res.partner:0
-msgid "Geo Localization"
-msgstr "Geo-Localizzazione"
-
-#. module: partner_geo_assign
-#: code:addons/partner_geo_assign/partner_geo_assign.py:0
-#, python-format
-msgid ""
-"Could not contact geolocation servers, please make sure you have a working "
-"internet connection (%s)"
-msgstr ""
-"Non è possibile contattare i server per la geo-localizzaziome, per favore "
-"assicurarsi di avere una connessione ad internet funzionante (%s)"
-
-#. module: partner_geo_assign
-#: constraint:ir.model:0
-msgid ""
-"The Object name must start with x_ and not contain any special character !"
-msgstr ""
-"Il nome dell'oggetto deve iniziare per x_ e non deve contenere caratteri "
-"speciali!"
-
-#. module: partner_geo_assign
-#: field:res.partner,date_localization:0
-msgid "Geo Localization Date"
-msgstr "Data Geo-localizzazione"
-
-#. module: partner_geo_assign
-#: view:crm.lead:0
-msgid "Geo Assign"
-msgstr "Geo assegnamento"
-
-#. module: partner_geo_assign
-#: field:crm.lead,partner_latitude:0
-#: field:res.partner,partner_latitude:0
-msgid "Geo Latitude"
-msgstr "Geo Latitudine"
-
-#. module: partner_geo_assign
-#: model:ir.model,name:partner_geo_assign.model_crm_lead
-msgid "crm.lead"
-msgstr "crm.lead"
-
-#. module: partner_geo_assign
-#: model:ir.model,name:partner_geo_assign.model_res_partner
-msgid "Partner"
-msgstr "Partner"
-
-#. module: partner_geo_assign
-#: view:crm.lead:0
-msgid "Geo Assignation"
-msgstr "Geo Assegnazione"
-
-#. module: partner_geo_assign
-#: view:res.partner:0
-msgid "Geo Localize"
-msgstr "Geo Localizzazione"
-
-#. module: partner_geo_assign
-#: field:crm.lead,partner_longitude:0
-#: field:res.partner,partner_longitude:0
-msgid "Geo Longitude"
-msgstr "Geo Longitudine"
diff --git a/addons/point_of_sale/__init__.py b/addons/point_of_sale/__init__.py
index 88f00077d16..be73103125f 100644
--- a/addons/point_of_sale/__init__.py
+++ b/addons/point_of_sale/__init__.py
@@ -19,7 +19,7 @@
#
##############################################################################
-import pos
+import point_of_sale
import account_bank_statement
import wizard
import report
diff --git a/addons/point_of_sale/__openerp__.py b/addons/point_of_sale/__openerp__.py
index 1c23a27acd1..6e742830148 100644
--- a/addons/point_of_sale/__openerp__.py
+++ b/addons/point_of_sale/__openerp__.py
@@ -62,18 +62,18 @@ Main features :
'wizard/pos_payment.xml',
'wizard/pos_scan_product_view.xml',
'wizard/pos_return_view.xml',
- 'pos_report.xml',
- 'pos_view.xml',
+ 'point_of_sale_report.xml',
+ 'point_of_sale_view.xml',
'report/report_pos_order_view.xml',
'report/report_cash_register_view.xml',
- 'pos_sequence.xml',
- 'pos_workflow.xml',
- 'statement_view.xml',
- 'statement_report.xml',
+ 'point_of_sale_sequence.xml',
+ 'point_of_sale_workflow.xml',
+ 'account_statement_view.xml',
+ 'account_statement_report.xml',
],
- 'demo_xml': ['pos_demo.xml','singer_statement_demo.xml'],
- 'test':['test/pos_test.yml',
- 'test/pos_report.yml',
+ 'demo_xml': ['point_of_sale_demo.xml','account_statement_demo.xml'],
+ 'test': ['test/point_of_sale_test.yml',
+ 'test/point_of_sale_report.yml',
],
'installable': True,
}
diff --git a/addons/point_of_sale/account_bank_statement.py b/addons/point_of_sale/account_bank_statement.py
index 28d3befe3c2..9cf50f6d018 100644
--- a/addons/point_of_sale/account_bank_statement.py
+++ b/addons/point_of_sale/account_bank_statement.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2008 PC Solutions (). All Rights Reserved
# Copyright (C) 2004-2010 Tiny SPRL ().
@@ -16,21 +16,19 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
+# along with this program. If not, see .
#
##############################################################################
-from osv import osv
-from osv import fields
+from osv import fields, osv
class account_journal(osv.osv):
-
_inherit = 'account.journal'
_columns = {
'auto_cash': fields.boolean('Automatic Opening', help="This field authorize the automatic creation of the cashbox"),
'special_journal': fields.boolean('Special Journal', help="Will put all the orders in waiting status till being accepted"),
'check_dtls': fields.boolean('Check Details', help="This field authorize Validation of Cashbox without checking ending details"),
- 'journal_users': fields.many2many('res.users','pos_journal_users','journal_id','user_id','Users'),
+ 'journal_users': fields.many2many('res.users', 'pos_journal_users', 'journal_id', 'user_id', 'Users'),
}
_defaults = {
'check_dtls': False,
@@ -39,7 +37,7 @@ class account_journal(osv.osv):
account_journal()
class account_cash_statement(osv.osv):
-
+
_inherit = 'account.bank.statement'
def _equal_balance(self, cr, uid, cash_id, context=None):
@@ -48,12 +46,11 @@ class account_cash_statement(osv.osv):
statement = self.browse(cr, uid, cash_id, context=context)
if not statement.journal_id.check_dtls:
return True
-
if statement.journal_id.check_dtls and (statement.balance_end != statement.balance_end_cash):
return False
else:
- return True
-
+ return True
+
def _user_allow(self, cr, uid, statement_id, context=None):
if context is None:
context = {}
@@ -62,12 +59,10 @@ class account_cash_statement(osv.osv):
statement = self.browse(cr, uid, statement_id, context=context)
for user in statement.journal_id.journal_users:
uids.append(user.id)
-
if uid in uids:
res = True
-
return res
-
+
def _get_cash_open_box_lines(self, cr, uid, context=None):
if context is None:
context = {}
@@ -81,7 +76,7 @@ class account_cash_statement(osv.osv):
res.append(dct)
res.sort()
return res
-
+
def _get_default_cash_close_box_lines(self, cr, uid, context=None):
if context is None:
context = {}
@@ -95,7 +90,7 @@ class account_cash_statement(osv.osv):
res.append(dct)
res.sort()
return res
-
+
account_cash_statement()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/point_of_sale/singer_statement_demo.xml b/addons/point_of_sale/account_statement_demo.xml
similarity index 100%
rename from addons/point_of_sale/singer_statement_demo.xml
rename to addons/point_of_sale/account_statement_demo.xml
diff --git a/addons/point_of_sale/statement_report.xml b/addons/point_of_sale/account_statement_report.xml
similarity index 100%
rename from addons/point_of_sale/statement_report.xml
rename to addons/point_of_sale/account_statement_report.xml
diff --git a/addons/point_of_sale/statement_view.xml b/addons/point_of_sale/account_statement_view.xml
similarity index 100%
rename from addons/point_of_sale/statement_view.xml
rename to addons/point_of_sale/account_statement_view.xml
diff --git a/addons/point_of_sale/statement_wizard.xml b/addons/point_of_sale/account_statement_wizard.xml
similarity index 100%
rename from addons/point_of_sale/statement_wizard.xml
rename to addons/point_of_sale/account_statement_wizard.xml
diff --git a/addons/point_of_sale/pos.py b/addons/point_of_sale/point_of_sale.py
similarity index 79%
rename from addons/point_of_sale/pos.py
rename to addons/point_of_sale/point_of_sale.py
index 6429e21c08d..41f3274c667 100644
--- a/addons/point_of_sale/pos.py
+++ b/addons/point_of_sale/point_of_sale.py
@@ -20,10 +20,11 @@
##############################################################################
import time
-import netsvc
-from osv import fields, osv
from datetime import datetime
from dateutil.relativedelta import relativedelta
+
+import netsvc
+from osv import fields, osv
from tools.translate import _
from decimal import Decimal
import decimal_precision as dp
@@ -39,63 +40,55 @@ class pos_config_journal(osv.osv):
}
pos_config_journal()
+
class pos_company_discount(osv.osv):
-
""" Company Discount and Cashboxes """
-
_inherit = 'res.company'
_columns = {
- 'company_discount': fields.float('Max Discount(%)', digits_compute= dp.get_precision('Point Of Sale')),
- 'max_diff': fields.float('Max Difference for Cashboxes', digits_compute= dp.get_precision('Point Of Sale Discount')),
- }
+ 'company_discount': fields.float('Max Discount(%)', digits_compute=dp.get_precision('Point Of Sale')),
+ 'max_diff': fields.float('Max Difference for Cashboxes', digits_compute=dp.get_precision('Point Of Sale Discount')),
+ }
pos_company_discount()
class pos_order(osv.osv):
-
""" Point of sale gives business owners a convenient way of checking out customers
and of recording sales """
_name = "pos.order"
_description = "Point of Sale"
_order = "date_order, create_date desc"
- _order = "date_order desc"
-
def unlink(self, cr, uid, ids, context=None):
for rec in self.browse(cr, uid, ids, context=context):
for rec_statement in rec.statement_ids:
- if (rec_statement.statement_id and rec_statement.statement_id.state=='confirm') or rec.state=='done':
+ if (rec_statement.statement_id and rec_statement.statement_id.state == 'confirm') or rec.state == 'done':
raise osv.except_osv(_('Invalid action !'), _('Cannot delete a point of sale which is closed or contains confirmed cashboxes!'))
return super(pos_order, self).unlink(cr, uid, ids, context=context)
def onchange_partner_pricelist(self, cr, uid, ids, part, context=None):
-
""" Changed price list on_change of partner_id"""
-
if not part:
return {}
- pricelist = self.pool.get('res.partner').browse(cr, uid, part).property_product_pricelist.id
- return {'value':{'pricelist_id': pricelist}}
+ pricelist = self.pool.get('res.partner').browse(cr, uid, part, context=context).property_product_pricelist.id
+ return {'value': {'pricelist_id': pricelist}}
def _amount_total(self, cr, uid, ids, field_name, arg, context=None):
-
""" Calculates amount_tax of order line
@param field_names: Names of fields.
@return: Dictionary of values """
-
cr.execute("""
- SELECT
- p.id,
- COALESCE(SUM(
- l.price_unit*l.qty*(1-(l.discount/100.0)))::decimal(16,2), 0
- ) AS amount
- FROM pos_order p
- LEFT OUTER JOIN pos_order_line l ON (p.id=l.order_id)
- WHERE p.id IN %s GROUP BY p.id """,(tuple(ids),))
+ SELECT
+ p.id,
+ COALESCE(SUM(
+ l.price_unit*l.qty*(1-(l.discount/100.0)))::decimal(16,2), 0
+ ) AS amount
+ FROM pos_order p
+ LEFT OUTER JOIN pos_order_line l ON (p.id = l.order_id)
+ WHERE p.id IN %s GROUP BY p.id """,(tuple(ids),))
res = dict(cr.fetchall())
- for rec in self.browse(cr, uid, ids, context):
+ for rec in self.browse(cr, uid, ids, context=context):
if rec.partner_id \
and rec.partner_id.property_account_position \
and rec.partner_id.property_account_position.tax_ids:
@@ -105,81 +98,75 @@ class pos_order(osv.osv):
return res
def _get_date_payment2(self, cr, uid, ids, context, *a):
-
# Todo need to check this function
""" Find payment Date
-
@param field_names: Names of fields.
@return: Dictionary of values """
-
res = {}
- val=None
+ val = None
for order in self.browse(cr, uid, ids):
- cr.execute("SELECT date_payment FROM pos_order WHERE id=%s", (order.id,))
+ cr.execute("SELECT date_payment FROM pos_order WHERE id = %s", (order.id,))
date_p=cr.fetchone()
date_p=date_p and date_p[0] or None
if date_p:
res[order.id]=date_p
return res
- cr.execute(" SELECT max(l.date) "
+ cr.execute(" SELECT MAX(l.date) "
" FROM account_move_line l, account_move m, account_invoice i, account_move_reconcile r, pos_order o "
- " WHERE i.move_id=m.id AND l.move_id=m.id AND l.reconcile_id=r.id AND o.id=%s AND o.invoice_id=i.id",
+ " WHERE i.move_id = m.id AND l.move_id = m.id AND l.reconcile_id = r.id AND o.id = %s AND o.invoice_id = i.id",
(order.id,))
- val=cr.fetchone()
- val= val and val[0] or None
+ val = cr.fetchone()
+ val = val and val[0] or None
if val:
- res[order.id]=val
+ res[order.id] = val
return res
def _get_date_payment(self, cr, uid, ids, context, *a):
-
""" Find Validation Date
@return: Dictionary of values """
-
res = {}
- val=None
+ val = None
for order in self.browse(cr, uid, ids):
- cr.execute("SELECT date_validation FROM pos_order WHERE id=%s", (order.id,))
- date_p=cr.fetchone()
- date_p=date_p and date_p[0] or None
+ cr.execute("SELECT date_validation FROM pos_order WHERE id = %s", (order.id,))
+ date_p = cr.fetchone()
+ date_p = date_p and date_p[0] or None
if date_p:
- res[order.id]=date_p
+ res[order.id] = date_p
return res
- discount_allowed=order.company_id.company_discount
+ discount_allowed = order.company_id.company_discount
for line in order.lines:
if line.discount > discount_allowed:
return {order.id: None }
if order.amount_paid == order.amount_total and not date_p:
- cr.execute("SELECT MAX(date) FROM account_bank_statement_line WHERE pos_statement_id=%s", (order.id,))
- val=cr.fetchone()
- val=val and val[0] or None
+ cr.execute("SELECT MAX(date) FROM account_bank_statement_line WHERE pos_statement_id = %s", (order.id,))
+ val = cr.fetchone()
+ val = val and val[0] or None
if order.invoice_id and order.invoice_id.move_id and not date_p and not val:
for o in order.invoice_id.move_id.line_id:
- if o.balance==0:
- if val %s", (ids[0],comp))
- res2=cr.fetchone()
- cr.execute("select journal_id from account_bank_statement_line where pos_statement_id=%s ", (ids[0],))
- res3=cr.fetchall()
- list_jrnl=[]
+ comp = company_disc[0] and company_disc[0].company_id and company_disc[0].company_id.company_discount or 0.0
+ cr.execute("SELECT discount FROM pos_order_line WHERE order_id = %s AND discount <= %s", (ids[0], comp))
+ res = cr.fetchone()
+ cr.execute("SELECT discount FROM pos_order_line WHERE order_id = %s AND discount > %s", (ids[0], comp))
+ res2 = cr.fetchone()
+ cr.execute("SELECT journal_id FROM account_bank_statement_line WHERE pos_statement_id = %s ", (ids[0], ))
+ res3 = cr.fetchall()
for r in res3:
- cr.execute("select id from account_journal where name= '%s' and special_journal='t'", (r[0],))
- res3=cr.fetchone()
- is_special=res3 and res3[0] or None
+ cr.execute("SELECT id FROM account_journal WHERE name = '%s' AND special_journal = 't'", (r[0], ))
+ res3 = cr.fetchone()
+ is_special = res3 and res3[0] or None
if is_special:
list_jrnl.append(is_special)
- r = {}
for order in self.browse(cr, uid, ids):
- if order.state in ('paid','done','invoiced') and res and not res2 and not len(list_jrnl):
+ if order.state in ('paid', 'done', 'invoiced') and res and not res2 and not len(list_jrnl):
r[order.id] = 'accepted'
return r
@@ -269,8 +242,8 @@ class pos_order(osv.osv):
'shop_id': fields.many2one('sale.shop', 'Shop', required=True,
states={'draft': [('readonly', False)]}, readonly=True),
'date_order': fields.datetime('Date Ordered', readonly=True),
- 'date_validation': fields.function(_get_date_payment, method=True, string='Validation Date', type='date', store=True),
- 'date_payment': fields.function(_get_date_payment2, method=True, string='Payment Date', type='date', store=True),
+ 'date_validation': fields.function(_get_date_payment, method=True, string='Validation Date', type='date', store=True),
+ 'date_payment': fields.function(_get_date_payment2, method=True, string='Payment Date', type='date', store=True),
'date_validity': fields.date('Validity Date', required=True),
'user_id': fields.many2one('res.users', 'Connected Salesman', help="Person who uses the the register. It could be a reliever, a student or an interim employee."),
'user_salesman_id': fields.many2one('res.users', 'Cashier', required=True, help="User who is logged into the system."),
@@ -281,15 +254,19 @@ class pos_order(osv.osv):
'amount_return': fields.function(_amount_all, 'Returned', method=True, digits_compute=dp.get_precision('Point Of Sale'), multi='all'),
'lines': fields.one2many('pos.order.line', 'order_id', 'Order Lines', states={'draft': [('readonly', False)]}, readonly=True),
'price_type': fields.selection([
- ('tax_excluded','Tax excluded')
- ], 'Price method', required=True),
- 'statement_ids': fields.one2many('account.bank.statement.line','pos_statement_id','Payments',states={'draft': [('readonly', False)]},readonly=True),
+ ('tax_excluded','Tax excluded')],
+ 'Price method', required=True),
+ 'statement_ids': fields.one2many('account.bank.statement.line', 'pos_statement_id', 'Payments', states={'draft': [('readonly', False)]}, readonly=True),
'pricelist_id': fields.many2one('product.pricelist', 'Pricelist', required=True, states={'draft': [('readonly', False)]}, readonly=True),
- 'partner_id': fields.many2one( 'res.partner', 'Customer', change_default=True, select=1, states={'draft': [('readonly', False)], 'paid': [('readonly', False)]}),
- 'state': fields.selection([('draft', 'Quotation'), ('payment', 'Payment'),
- ('advance','Advance'),
- ('paid', 'Paid'), ('done', 'Done'), ('invoiced', 'Invoiced'), ('cancel', 'Cancel')],
- 'State', readonly=True, ),
+ 'partner_id': fields.many2one('res.partner', 'Customer', change_default=True, select=1, states={'draft': [('readonly', False)], 'paid': [('readonly', False)]}),
+ 'state': fields.selection([('draft', 'Quotation'),
+ ('payment', 'Payment'),
+ ('advance','Advance'),
+ ('paid', 'Paid'),
+ ('done', 'Done'),
+ ('invoiced', 'Invoiced'),
+ ('cancel', 'Cancel')],
+ 'State', readonly=True),
'invoice_id': fields.many2one('account.invoice', 'Invoice'),
'account_move': fields.many2one('account.move', 'Account Entry', readonly=True),
'pickings': fields.one2many('stock.picking', 'pos_order', 'Picking', readonly=True),
@@ -297,27 +274,23 @@ class pos_order(osv.osv):
'first_name': fields.char('First Name', size=64),
'note': fields.text('Internal Notes'),
'nb_print': fields.integer('Number of Print', readonly=True),
- 'sale_journal': fields.many2one('account.journal', 'Journal', required=True, states={'draft': [('readonly', False)]}, readonly=True, ),
+ 'sale_journal': fields.many2one('account.journal', 'Journal', required=True, states={'draft': [('readonly', False)]}, readonly=True),
'invoice_wanted': fields.boolean('Create Invoice'),
- 'note_2': fields.char('Customer Note',size=64),
- 'type_rec': fields.char('Type of Receipt',size=64),
+ 'note_2': fields.char('Customer Note', size=64),
+ 'type_rec': fields.char('Type of Receipt', size=64),
'remboursed': fields.boolean('Remboursed'),
'contract_number': fields.char('Contract Number', size=512, select=1),
'journal_entry': fields.boolean('Journal Entry'),
}
- def _select_pricelist(self, cr, uid, context):
-
+ def _select_pricelist(self, cr, uid, context=None):
""" To get default pricelist for the order"
@param name: Names of fields.
@return: pricelist ID
"""
- pricelist = self.pool.get('product.pricelist').search(cr, uid, [('name', '=', 'Public Pricelist')])
- if pricelist:
- return pricelist[0]
- else:
- return False
+ pricelist = self.pool.get('product.pricelist').search(cr, uid, [('name', '=', 'Public Pricelist')], context=context)
+ return pricelist and pricelist[0] or False
def _journal_default(self, cr, uid, context=None):
""" To get default pricelist for the order"
@@ -325,24 +298,21 @@ class pos_order(osv.osv):
@return: journal ID
"""
journal_list = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'cash')])
- if journal_list:
- return journal_list[0]
- else:
- return False
+ return journal_list and journal_list[0] or False
_defaults = {
'user_salesman_id':lambda self, cr, uid, context: uid,
'user_id': lambda self, cr, uid, context: uid,
'sale_manager': lambda self, cr, uid, context: uid,
- 'state': lambda *a: 'draft',
- 'price_type': lambda *a: 'tax_excluded',
+ 'state': 'draft',
+ 'price_type': 'tax_excluded',
'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'pos.order'),
- 'date_order': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
+ 'date_order': time.strftime('%Y-%m-%d %H:%M:%S'),
'date_validity': lambda *a: (datetime.today() + relativedelta(months=+6)).strftime('%Y-%m-%d'),
- 'nb_print': lambda *a: 0,
+ 'nb_print': 0,
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
'sale_journal': _sale_journal_get,
- 'invoice_wanted': lambda *a: False,
+ 'invoice_wanted': False,
'shop_id': _shop_get,
'pricelist_id': _select_pricelist,
}
@@ -364,22 +334,19 @@ class pos_order(osv.osv):
return True
def test_paid(self, cr, uid, ids, context=None):
-
""" Test all amount is paid for this order
@return: True
"""
- for order in self.browse(cr, uid, ids, context):
+ for order in self.browse(cr, uid, ids, context=context):
if order.lines and not order.amount_total:
return True
if (not order.lines) or (not order.statement_ids) or \
- Decimal(str(order.amount_total))!=Decimal(str(order.amount_paid)):
+ Decimal(str(order.amount_total)) != Decimal(str(order.amount_paid)):
return False
return True
def _get_qty_differences(self, orders, old_picking):
-
"""check if the customer changed the product quantity """
-
order_dict = {}
for order in orders:
for line in order.lines:
@@ -401,9 +368,7 @@ class pos_order(osv.osv):
return diff_dict
def _split_picking(self, cr, uid, ids, context, old_picking, diff_dict):
-
"""if the customer changes the product quantity, split the picking in two"""
-
# create a copy of the original picking and adjust the product qty:
picking_model = self.pool.get('stock.picking')
defaults = {
@@ -412,7 +377,7 @@ class pos_order(osv.osv):
}
new_picking_id = picking_model.copy(cr, uid, old_picking.id, defaults) # state = 'draft'
- new_picking = picking_model.browse(cr, uid, new_picking_id, context)
+ new_picking = picking_model.browse(cr, uid, new_picking_id, context=context)
for line in new_picking.move_lines:
p_id = line.product_id.id
@@ -442,17 +407,16 @@ class pos_order(osv.osv):
def create_picking(self, cr, uid, ids, context=None):
"""Create a picking for each order and validate it."""
-
picking_obj = self.pool.get('stock.picking')
- property_obj=self.pool.get("ir.property")
+ property_obj = self.pool.get("ir.property")
move_obj=self.pool.get('stock.move')
- pick_name=self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.out')
- orders = self.browse(cr, uid, ids, context)
+ pick_name = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.out')
+ orders = self.browse(cr, uid, ids, context=context)
for order in orders:
if not order.picking_id:
new = True
picking_id = picking_obj.create(cr, uid, {
- 'name':pick_name,
+ 'name': pick_name,
'origin': order.name,
'type': 'out',
'state': 'draft',
@@ -461,12 +425,12 @@ class pos_order(osv.osv):
'invoice_state': 'none',
'auto_picking': True,
'pos_order': order.id,
- })
- self.write(cr, uid, [order.id], {'picking_id': picking_id})
+ }, context=context)
+ self.write(cr, uid, [order.id], {'picking_id': picking_id}, context=context)
else:
picking_id = order.picking_id.id
- picking_obj.write(cr, uid, [picking_id], {'auto_picking': True})
- picking = picking_obj.browse(cr, uid, [picking_id], context)[0]
+ picking_obj.write(cr, uid, [picking_id], {'auto_picking': True}, context=context)
+ picking = picking_obj.browse(cr, uid, [picking_id], context=context)[0]
new = False
# split the picking (if product quantity has changed):
@@ -476,13 +440,13 @@ class pos_order(osv.osv):
if new:
for line in order.lines:
- if line.product_id and line.product_id.type=='service':
+ if line.product_id and line.product_id.type == 'service':
continue
- prop_ids = property_obj.search(cr, uid, [('name', '=', 'property_stock_customer')])
- val = property_obj.browse(cr, uid, prop_ids[0]).value_reference
- cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id=%s", (order.shop_id.warehouse_id.id,))
- res=cr.fetchone()
- location_id=res and res[0] or None
+ prop_ids = property_obj.search(cr, uid, [('name', '=', 'property_stock_customer')], context=context)
+ val = property_obj.browse(cr, uid, prop_ids[0], context=context).value_reference
+ cr.execute("SELECT s.id FROM stock_location s, stock_warehouse w WHERE w.lot_stock_id = s.id AND w.id = %s", (order.shop_id.warehouse_id.id, ))
+ res = cr.fetchone()
+ location_id = res and res[0] or None
stock_dest_id = val.id
if line.qty < 0:
location_id, stock_dest_id = stock_dest_id, location_id
@@ -500,37 +464,33 @@ class pos_order(osv.osv):
'state': 'waiting',
'location_id': location_id,
'location_dest_id': stock_dest_id,
- })
+ }, context=context)
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr)
- self.pool.get('stock.picking').force_assign(cr, uid, [picking_id], context)
+ picking_obj.force_assign(cr, uid, [picking_id], context)
return True
def set_to_draft(self, cr, uid, ids, *args):
-
""" Changes order state to draft
@return: True
"""
if not len(ids):
return False
-
self.write(cr, uid, ids, {'state': 'draft'})
-
wf_service = netsvc.LocalService("workflow")
for i in ids:
wf_service.trg_create(uid, 'pos.order', i, cr)
return True
def button_invalidate(self, cr, uid, ids, *args):
-
""" Check the access for the sale order
@return: True
"""
res_obj = self.pool.get('res.company')
try:
- part_company=res_obj.browse(cr,uid,uid) and res_obj.browse(cr,uid,uid).parent_id and res_obj.browse(cr,uid,uid).parent_id.id or None
+ part_company = res_obj.browse(cr, uid, uid) and res_obj.browse(cr, uid, uid).parent_id and res_obj.browse(cr, uid, uid).parent_id.id or None
except Exception:
raise osv.except_osv(_('Error'), _('You don\'t have enough access to validate this sale!'))
if part_company:
@@ -538,42 +498,39 @@ class pos_order(osv.osv):
return True
def cancel_order(self, cr, uid, ids, context=None):
-
""" Changes order state to cancel
@return: True
"""
- self.write(cr, uid, ids, {'state': 'cancel'})
+ self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
self.cancel_picking(cr, uid, ids, context=context)
return True
def add_payment(self, cr, uid, order_id, data, context=None):
-
"""Create a new payment for the order"""
-
statement_obj= self.pool.get('account.bank.statement')
- statementl_obj = self.pool.get('account.bank.statement.line')
+ statement_line_obj = self.pool.get('account.bank.statement.line')
prod_obj = self.pool.get('product.product')
- property_obj=self.pool.get('ir.property')
- curr_c=self.pool.get('res.users').browse(cr, uid, uid).company_id
- curr_company=curr_c.id
- order = self.browse(cr, uid, order_id, context)
+ property_obj = self.pool.get('ir.property')
+ curr_c = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id
+ curr_company = curr_c.id
+ order = self.browse(cr, uid, order_id, context=context)
if not order.num_sale and data['num_sale']:
- self.write(cr,uid,order_id,{'num_sale': data['num_sale']})
- ids_new=[]
+ self.write(cr, uid, order_id, {'num_sale': data['num_sale']}, context=context)
+ ids_new = []
args = {
'amount': data['amount'],
}
if 'payment_date' in data.keys():
args['date'] = data['payment_date']
if 'payment_name' in data.keys():
- args['name'] = data['payment_name'] + ' ' +order.name
+ args['name'] = data['payment_name'] + ' ' + order.name
account_def = property_obj.get(cr, uid, 'property_account_receivable', 'res.partner', context=context)
args['account_id'] = order.partner_id and order.partner_id.property_account_receivable and order.partner_id.property_account_receivable.id or account_def.id or curr_c.account_receivable.id
- if data.get('is_acc',False):
+ if data.get('is_acc', False):
args['is_acc'] = data['is_acc']
- args['account_id']= prod_obj.browse(cr,uid, data['product_id']).property_account_income and prod_obj.browse(cr,uid, data['product_id']).property_account_income.id
+ args['account_id'] = prod_obj.browse(cr, uid, data['product_id'], context=context).property_account_income and prod_obj.browse(cr, uid, data['product_id'], context=context).property_account_income.id
if not args['account_id']:
- raise osv.except_osv(_('Error'), _('Please provide an account for the product: %s')%(prod_obj.browse(cr,uid, data['product_id']).name))
+ raise osv.except_osv(_('Error'), _('Please provide an account for the product: %s')%(prod_obj.browse(cr, uid, data['product_id'], context=context).name))
args['partner_id'] = order.partner_id and order.partner_id.id or None
args['ref'] = order.contract_number or None
@@ -581,15 +538,15 @@ class pos_order(osv.osv):
('journal_id', '=', data['journal']),
('company_id', '=', curr_company),
('user_id', '=', uid),
- ('state', '=', 'open')])
- if len(statement_id)==0:
+ ('state', '=', 'open')], context=context)
+ if len(statement_id) == 0:
raise osv.except_osv(_('Error !'), _('You have to open at least one cashbox'))
if statement_id:
- statement_id=statement_id[0]
- args['statement_id']= statement_id
- args['pos_statement_id']= order_id
- args['journal_id']= data['journal']
- statementl_obj.create(cr, uid, args)
+ statement_id = statement_id[0]
+ args['statement_id'] = statement_id
+ args['pos_statement_id'] = order_id
+ args['journal_id'] = data['journal']
+ statement_line_obj.create(cr, uid, args, context=context)
ids_new.append(statement_id)
wf_service = netsvc.LocalService("workflow")
@@ -599,9 +556,7 @@ class pos_order(osv.osv):
return statement_id
def add_product(self, cr, uid, order_id, product_id, qty, context=None):
-
"""Create a new order line the order"""
-
line_obj = self.pool.get('pos.order.line')
values = self.read(cr, uid, order_id, ['partner_id', 'pricelist_id'])
@@ -616,10 +571,9 @@ class pos_order(osv.osv):
'product_id': product_id,
'qty': qty,
'price_unit': price,
- })
+ }, context=context)
wf_service = netsvc.LocalService("workflow")
wf_service.trg_write(uid, 'pos.order', order_id, cr)
-
return order_line_id, price
def refund(self, cr, uid, ids, context=None):
@@ -627,7 +581,7 @@ class pos_order(osv.osv):
clone_list = []
line_obj = self.pool.get('pos.order.line')
- for order in self.browse(cr, uid, ids):
+ for order in self.browse(cr, uid, ids, context=context):
clone_id = self.copy(cr, uid, order.id, {
'name': order.name + ' REFUND',
'date_order': time.strftime('%Y-%m-%d'),
@@ -636,26 +590,25 @@ class pos_order(osv.osv):
'invoice_id': False,
'nb_print': 0,
'statement_ids': False,
- })
+ }, context=context)
clone_list.append(clone_id)
- for clone in self.browse(cr, uid, clone_list):
+ for clone in self.browse(cr, uid, clone_list, context=context):
for order_line in clone.lines:
line_obj.write(cr, uid, [order_line.id], {
'qty': -order_line.qty
- })
+ }, context=context)
return clone_list
def action_invoice(self, cr, uid, ids, context=None):
"""Create a invoice of order """
-
inv_ref = self.pool.get('account.invoice')
inv_line_ref = self.pool.get('account.invoice.line')
- product_obj= self.pool.get('product.product')
+ product_obj = self.pool.get('product.product')
inv_ids = []
- for order in self.pool.get('pos.order').browse(cr, uid, ids, context):
+ for order in self.pool.get('pos.order').browse(cr, uid, ids, context=context):
if order.invoice_id:
inv_ids.append(order.invoice_id.id)
continue
@@ -663,12 +616,12 @@ class pos_order(osv.osv):
if not order.partner_id:
raise osv.except_osv(_('Error'), _('Please provide a partner for the sale.'))
- acc= order.partner_id.property_account_receivable.id
+ acc = order.partner_id.property_account_receivable.id
inv = {
'name': 'Invoice from POS: '+order.name,
'origin': order.name,
- 'account_id':acc,
- 'journal_id':order.sale_journal.id or None,
+ 'account_id': acc,
+ 'journal_id': order.sale_journal.id or None,
'type': 'out_invoice',
'reference': order.name,
'partner_id': order.partner_id.id,
@@ -677,9 +630,9 @@ class pos_order(osv.osv):
inv.update(inv_ref.onchange_partner_id(cr, uid, [], 'out_invoice', order.partner_id.id)['value'])
if not inv.get('account_id', None):
inv['account_id'] = acc
- inv_id = inv_ref.create(cr, uid, inv, context)
+ inv_id = inv_ref.create(cr, uid, inv, context=context)
- self.write(cr, uid, [order.id], {'invoice_id': inv_id, 'state': 'invoiced'})
+ self.write(cr, uid, [order.id], {'invoice_id': inv_id, 'state': 'invoiced'}, context=context)
inv_ids.append(inv_id)
for line in order.lines:
inv_line = {
@@ -697,10 +650,9 @@ class pos_order(osv.osv):
inv_line['discount'] = line.discount
inv_line['account_id'] = acc
inv_line['name'] = inv_name
-
inv_line['invoice_line_tax_id'] = ('invoice_line_tax_id' in inv_line)\
and [(6, 0, inv_line['invoice_line_tax_id'])] or []
- inv_line_ref.create(cr, uid, inv_line, context)
+ inv_line_ref.create(cr, uid, inv_line, context=context)
for i in inv_ids:
wf_service = netsvc.LocalService("workflow")
@@ -708,9 +660,7 @@ class pos_order(osv.osv):
return inv_ids
def create_account_move(self, cr, uid, ids, context=None):
-
"""Create a account move line of order """
-
account_move_obj = self.pool.get('account.move')
account_move_line_obj = self.pool.get('account.move.line')
account_period_obj = self.pool.get('account.period')
@@ -720,9 +670,9 @@ class pos_order(osv.osv):
period = account_period_obj.find(cr, uid, context=context)[0]
for order in self.browse(cr, uid, ids, context=context):
- curr_c =res_obj.browse(cr, uid, uid).company_id
+ curr_c = res_obj.browse(cr, uid, uid).company_id
comp_id = res_obj.browse(cr, order.user_id.id, order.user_id.id).company_id
- comp_id=comp_id and comp_id.id or False
+ comp_id = comp_id and comp_id.id or False
to_reconcile = []
group_tax = {}
account_def = property_obj.get(cr, uid, 'property_account_receivable', 'res.partner', context=context).id
@@ -737,10 +687,9 @@ class pos_order(osv.osv):
# Create an move for each order line
for line in order.lines:
-
tax_amount = 0
taxes = [t for t in line.product_id.taxes_id]
- if order.price_type=='tax_excluded':
+ if order.price_type == 'tax_excluded':
computed_taxes = account_tax_obj.compute_all(
cr, uid, taxes, line.price_unit, line.qty)['taxes']
else:
@@ -757,7 +706,7 @@ class pos_order(osv.osv):
group_tax[group_key] += round(tax['amount'], 2)
else:
group_tax[group_key] = round(tax['amount'], 2)
- if order.price_type!='tax_excluded':
+ if order.price_type != 'tax_excluded':
amount = line.price_subtotal - tax_amount
else:
amount = line.price_subtotal
@@ -775,7 +724,6 @@ class pos_order(osv.osv):
'account defined for this product: "%s" (id:%d)') \
% (line.product_id.name, line.product_id.id, ))
-
# Empty the tax list as long as there is no tax code:
tax_code_id = False
tax_amount = 0
@@ -797,7 +745,7 @@ class pos_order(osv.osv):
'date': order.date_order[:10],
'ref': order.contract_number or order.name,
'quantity': line.qty,
- 'product_id':line.product_id.id,
+ 'product_id': line.product_id.id,
'move_id': move_id,
'account_id': income_account,
'company_id': comp_id,
@@ -821,7 +769,7 @@ class pos_order(osv.osv):
continue
account_move_line_obj.create(cr, uid, {
- 'name': "bb"+order.name,
+ 'name': "bb" + order.name,
'date': order.date_order[:10],
'ref': order.contract_number or order.name,
'product_id':line.product_id.id,
@@ -842,13 +790,13 @@ class pos_order(osv.osv):
(tax_code_pos, base_code_pos, account_pos)= (0, 1, 2)
for key, amount in group_tax.items():
account_move_line_obj.create(cr, uid, {
- 'name':"cc"+order.name,
+ 'name': "cc" + order.name,
'date': order.date_order[:10],
'ref': order.contract_number or order.name,
'move_id': move_id,
'company_id': comp_id,
'quantity': line.qty,
- 'product_id':line.product_id.id,
+ 'product_id': line.product_id.id,
'account_id': key[account_pos],
'credit': ((amount>0) and amount) or 0.0,
'debit': ((amount<0) and -amount) or 0.0,
@@ -860,15 +808,15 @@ class pos_order(osv.osv):
# counterpart
to_reconcile.append(account_move_line_obj.create(cr, uid, {
- 'name': "dd"+order.name,
+ 'name': "dd" + order.name,
'date': order.date_order[:10],
'ref': order.contract_number or order.name,
'move_id': move_id,
'company_id': comp_id,
'account_id': order_account,
- 'credit': ((order.amount_total<0) and -order.amount_total)\
+ 'credit': ((order.amount_total < 0) and -order.amount_total)\
or 0.0,
- 'debit': ((order.amount_total>0) and order.amount_total)\
+ 'debit': ((order.amount_total > 0) and order.amount_total)\
or 0.0,
'journal_id': order.sale_journal.id,
'period_id': period,
@@ -882,7 +830,6 @@ class pos_order(osv.osv):
_('There is no receivable account defined for this journal:'\
' "%s" (id:%d)') % (order.sale_journal.name, order.sale_journal.id, ))
for payment in order.statement_ids:
-
# Create one entry for the payment
if payment.is_acc:
continue
@@ -903,23 +850,24 @@ class pos_order(osv.osv):
})
account_move_line_obj.copy(cr, uid, s.id, {
'statement_id': False,
- 'account_id':order_account
+ 'account_id': order_account
})
- self.write(cr,uid,order.id,{'state':'done'})
+ self.write(cr, uid, order.id, {'state':'done'}, context=context)
return True
def cancel_picking(self, cr, uid, ids, context=None):
+ stock_picking_obj = self.pool.get('stock.picking')
for order in self.browse(cr, uid, ids, context=context):
for picking in order.pickings:
- self.pool.get('stock.picking').unlink(cr, uid, [picking.id], context)
+ stock_picking_obj.unlink(cr, uid, [picking.id], context=context)
return True
def action_payment(self, cr, uid, ids, context=None):
vals = {'state': 'payment'}
- sequence_obj=self.pool.get('ir.sequence')
- for pos in self.browse(cr, uid, ids):
+ sequence_obj = self.pool.get('ir.sequence')
+ for pos in self.browse(cr, uid, ids, context=context):
create_contract_nb = False
for line in pos.lines:
if line.product_id.product_type == 'MD':
@@ -927,21 +875,21 @@ class pos_order(osv.osv):
break
if create_contract_nb:
seq = sequence_obj.get(cr, uid, 'pos.user_%s' % pos.user_salesman_id.login)
- vals['contract_number'] ='%s-%s' % (pos.user_salesman_id.login, seq)
- self.write(cr, uid, ids, vals)
+ vals['contract_number'] = '%s-%s' % (pos.user_salesman_id.login, seq)
+ self.write(cr, uid, ids, vals, context=context)
def action_paid(self, cr, uid, ids, context=None):
if not context:
context = {}
- if context.get('flag',False):
+ if context.get('flag', False):
self.create_picking(cr, uid, ids, context=None)
- self.write(cr, uid, ids, {'state': 'paid'})
+ self.write(cr, uid, ids, {'state': 'paid'}, context=context)
else:
- context['flag']=True
+ context['flag'] = True
return True
def action_cancel(self, cr, uid, ids, context=None):
- self.write(cr, uid, ids, {'state': 'cancel'})
+ self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
return True
def action_done(self, cr, uid, ids, context=None):
@@ -951,12 +899,12 @@ class pos_order(osv.osv):
return True
def compute_state(self, cr, uid, id):
- cr.execute("select act.id, act.name from wkf_activity act "
- "inner join wkf_workitem item on act.id=item.act_id "
- "inner join wkf_instance inst on item.inst_id=inst.id "
- "inner join wkf on inst.wkf_id=wkf.id "
- "where wkf.osv='pos.order' and inst.res_id=%s "
- "order by act.name", (id,))
+ cr.execute("SELECT act.id, act.name FROM wkf_activity act "
+ "INNER JOIN wkf_workitem item ON act.id = item.act_id "
+ "INNER JOIN wkf_instance inst ON item.inst_id = inst.id "
+ "INNER JOIN wkf ON inst.wkf_id = wkf.id "
+ "WHERE wkf.osv = 'pos.order' AND inst.res_id = %s "
+ "ORDER BY act.name", (id, ))
return [name for id, name in cr.fetchall()]
pos_order()
@@ -964,7 +912,7 @@ pos_order()
class account_bank_statement(osv.osv):
_inherit = 'account.bank.statement'
_columns= {
- 'user_id': fields.many2one('res.users',ondelete='cascade',string='User', readonly=True),
+ 'user_id': fields.many2one('res.users', ondelete='cascade', string='User', readonly=True),
}
_defaults = {
'user_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).id
@@ -980,9 +928,9 @@ class account_bank_statement_line(osv.osv):
return res
_columns= {
'journal_id': fields.function(_get_statement_journal, method=True,store=True, string='Journal', type='char', size=64),
- 'am_out':fields.boolean("To count"),
- 'is_acc':fields.boolean("Is accompte"),
- 'pos_statement_id': fields.many2one('pos.order',ondelete='cascade'),
+ 'am_out': fields.boolean("To count"),
+ 'is_acc': fields.boolean("Is accompte"),
+ 'pos_statement_id': fields.many2one('pos.order', ondelete='cascade'),
}
account_bank_statement_line()
@@ -990,18 +938,18 @@ class pos_order_line(osv.osv):
_name = "pos.order.line"
_description = "Lines of Point of Sale"
- def _get_amount(self, cr, uid, ids, field_name, arg, context):
+ def _get_amount(self, cr, uid, ids, field_name, arg, context=None):
res = {}
- for line in self.browse(cr, uid, ids):
+ for line in self.browse(cr, uid, ids, context=context):
price = self.price_by_product(cr, uid, ids, line.order_id.pricelist_id.id, line.product_id.id, line.qty, line.order_id.partner_id.id)
- res[line.id]=price
+ res[line.id] = price
return res
- def _amount_line_ttc(self, cr, uid, ids, field_name, arg, context):
+ def _amount_line_ttc(self, cr, uid, ids, field_name, arg, context=None):
res = dict.fromkeys(ids, 0.0)
account_tax_obj = self.pool.get('account.tax')
self.price_by_product_multi(cr, uid, ids)
- for line in self.browse(cr, uid, ids):
+ for line in self.browse(cr, uid, ids, context=context):
tax_amount = 0.0
taxes = [t for t in line.product_id.taxes_id]
if line.qty == 0.0:
@@ -1009,27 +957,25 @@ class pos_order_line(osv.osv):
computed_taxes = account_tax_obj.compute_all(cr, uid, taxes, line.price_unit, line.qty)['taxes']
for tax in computed_taxes:
tax_amount += tax['amount']
- if line.discount!=0.0:
+ if line.discount != 0.0:
res[line.id] = line.price_unit * line.qty * (1 - (line.discount or 0.0) / 100.0)
else:
- res[line.id]=line.price_unit*line.qty
+ res[line.id] = line.price_unit*line.qty
res[line.id] = res[line.id] + tax_amount
return res
- def _amount_line(self, cr, uid, ids, field_name, arg, context):
+ def _amount_line(self, cr, uid, ids, field_name, arg, context=None):
res = {}
-
self.price_by_product_multi(cr, uid, ids)
- for line in self.browse(cr, uid, ids):
+ for line in self.browse(cr, uid, ids, context=context):
if line.discount!=0.0:
res[line.id] = line.price_unit * line.qty * (1 - (line.discount or 0.0) / 100.0)
else:
- res[line.id]=line.price_unit*line.qty
+ res[line.id] = line.price_unit * line.qty
return res
def _amount_line_all(self, cr, uid, ids, field_names, arg, context):
res = dict([(i, {}) for i in ids])
-
account_tax_obj = self.pool.get('account.tax')
self.price_by_product_multi(cr, uid, ids)
@@ -1059,9 +1005,7 @@ class pos_order_line(osv.osv):
def price_by_product_multi(self, cr, uid, ids, context=None):
if context is None:
context = {}
-
res = {}.fromkeys(ids, 0.0)
-
lines = self.browse(cr, uid, ids, context=context)
pricelist_ids = [line.order_id.pricelist_id.id for line in lines]
@@ -1105,10 +1049,10 @@ class pos_order_line(osv.osv):
raise osv.except_osv(_('No Pricelist !'),
_('You have to select a pricelist in the sale form !\n' \
'Please set one before choosing a product.'))
- p_obj = self.pool.get('product.product').browse(cr,uid,[product_id])[0]
+ p_obj = self.pool.get('product.product').browse(cr, uid, [product_id])[0]
uom_id = p_obj.uom_po_id.id
price = self.pool.get('product.pricelist').price_get(cr, uid,
- [pricelist], product_id, qty or 1.0, partner_id,{'uom': uom_id})[pricelist]
+ [pricelist], product_id, qty or 1.0, partner_id, {'uom': uom_id})[pricelist]
unit_price=price or p_obj.list_price
if unit_price is False:
raise osv.except_osv(_('No valid pricelist line found !'),
@@ -1119,38 +1063,38 @@ class pos_order_line(osv.osv):
def onchange_product_id(self, cr, uid, ids, pricelist, product_id, qty=0, partner_id=False):
price = self.price_by_product(cr, uid, ids, pricelist, product_id, qty, partner_id)
- self.write(cr,uid,ids,{'price_unit':price})
+ self.write(cr, uid, ids, {'price_unit':price})
pos_stot = (price * qty)
- return {'value': {'price_unit': price,'price_subtotal_incl': pos_stot}}
+ return {'value': {'price_unit': price, 'price_subtotal_incl': pos_stot}}
- def onchange_subtotal(self, cr, uid, ids, discount, price, pricelist,qty,partner_id, product_id,*a):
+ def onchange_subtotal(self, cr, uid, ids, discount, price, pricelist, qty,partner_id, product_id, *a):
prod_obj = self.pool.get('product.product')
price_f = self.price_by_product(cr, uid, ids, pricelist, product_id, qty, partner_id)
- prod_id=''
+ prod_id = ''
if product_id:
- prod_id=prod_obj.browse(cr,uid,product_id).disc_controle
- disc=0.0
- if (disc != 0.0 or prod_id) and price_f>0:
- disc=100-(price/price_f*100)
- return {'value':{'discount':disc, 'price_unit':price_f}}
+ prod_id = prod_obj.browse(cr, uid, product_id).disc_controle
+ disc = 0.0
+ if (disc != 0.0 or prod_id) and price_f > 0:
+ disc = 100 - (price/price_f*100)
+ return {'value': {'discount': disc, 'price_unit': price_f}}
return {}
- def onchange_dis(self, cr, uid,ids, qty, price_subtotal_incl, discount,*a):
+ def onchange_dis(self, cr, uid, ids, qty, price_subtotal_incl, discount, *a):
price_sub = price_subtotal_incl
- sub_total_discount = price_sub-(price_subtotal_incl*(discount*0.01))
- return {'value': {'price_subtotal_incl':sub_total_discount}}
+ sub_total_discount = price_sub - (price_subtotal_incl*(discount*0.01))
+ return {'value': {'price_subtotal_incl': sub_total_discount}}
- def onchange_ded(self, cr, uid,ids, val_ded,price_u,*a):
+ def onchange_ded(self, cr, uid, ids, val_ded, price_u, *a):
res_obj = self.pool.get('res.users')
- comp = res_obj.browse(cr,uid,uid).company_id.company_discount or 0.0
- val=0.0
+ comp = res_obj.browse(cr, uid, uid).company_id.company_discount or 0.0
+ val = 0.0
if val_ded and price_u:
- val=100.0*val_ded/price_u
+ val=100.0 * val_ded / price_u
if val > comp:
- return {'value': {'discount':val, 'notice':'' }}
- return {'value': {'discount':val}}
+ return {'value': {'discount': val, 'notice': '' }}
+ return {'value': {'discount': val}}
- def onchange_discount(self, cr, uid,ids, discount,price,*a):
+ def onchange_discount(self, cr, uid, ids, discount, price, *a):
pos_order = self.pool.get('pos.order.line')
res_obj = self.pool.get('res.users')
company_disc = pos_order.browse(cr,uid,ids)
@@ -1161,11 +1105,11 @@ class pos_order_line(osv.osv):
comp= company_disc[0] and company_disc[0].order_id.company_id and company_disc[0].order_id.company_id.company_discount or 0.0
if discount > comp :
- return {'value': {'notice':'','price_ded':price*discount*0.01 or 0.0 }}
+ return {'value': {'notice': '', 'price_ded': price * discount * 0.01 or 0.0 }}
else:
- return {'value': {'notice':'Minimum Discount','price_ded':price*discount*0.01 or 0.0 }}
+ return {'value': {'notice': 'Minimum Discount', 'price_ded': price * discount * 0.01 or 0.0 }}
else :
- return {'value': {'notice':'No Discount', 'price_ded':price*discount*0.01 or 0.0}}
+ return {'value': {'notice': 'No Discount', 'price_ded': price * discount * 0.01 or 0.0}}
def onchange_qty(self, cr, uid, ids, discount, qty, price, context=None):
subtotal = qty * price
@@ -1175,12 +1119,12 @@ class pos_order_line(osv.osv):
_columns = {
'name': fields.char('Line Description', size=512),
- 'company_id':fields.many2one('res.company', 'Company', required=True),
+ 'company_id': fields.many2one('res.company', 'Company', required=True),
'notice': fields.char('Discount Notice', size=128, required=True),
'serial_number': fields.char('Serial Number', size=128),
'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)], required=True, change_default=True),
'price_unit': fields.function(_get_amount, method=True, string='Unit Price', store=True),
- 'price_ded': fields.float('Discount(Amount)',digits_compute=dp.get_precision('Point Of Sale')),
+ 'price_ded': fields.float('Discount(Amount)', digits_compute=dp.get_precision('Point Of Sale')),
'qty': fields.float('Quantity'),
'qty_rfd': fields.float('Refunded Quantity'),
'price_subtotal': fields.function(_amount_line_all, method=True, multi='pos_order_line_amount', string='Subtotal w/o Tax'),
@@ -1201,17 +1145,17 @@ class pos_order_line(osv.osv):
def create(self, cr, user, vals, context=None):
if vals.get('product_id'):
- return super(pos_order_line, self).create(cr, user, vals, context)
+ return super(pos_order_line, self).create(cr, user, vals, context=context)
return False
def write(self, cr, user, ids, values, context=None):
if 'product_id' in values and not values['product_id']:
return False
- return super(pos_order_line, self).write(cr, user, ids, values, context)
+ return super(pos_order_line, self).write(cr, user, ids, values, context=context)
def _scan_product(self, cr, uid, ean, qty, order):
# search pricelist_id
- product_obj=self.pool.get('product.product')
+ product_obj = self.pool.get('product.product')
pricelist_id = self.pool.get('pos.order').read(cr, uid, [order], ['pricelist_id'] )
if not pricelist_id:
return False
@@ -1223,11 +1167,11 @@ class pos_order_line(osv.osv):
return False
# search price product
- product =product_obj.read(cr, uid, product_id)
+ product = product_obj.read(cr, uid, product_id)
product_name = product[0]['name']
price = self.price_by_product(cr, uid, 0, pricelist_id[0]['pricelist_id'][0], product_id[0], 1)
- order_line_ids = self.search(cr, uid, [('name','=',product_name),('order_id','=',order)])
+ order_line_ids = self.search(cr, uid, [('name', '=', product_name), ('order_id', '=' ,order)])
if order_line_ids:
new_line = False
order_line_id = order_line_ids[0]
@@ -1253,7 +1197,7 @@ class pos_order_line(osv.osv):
raise osv.except_osv(_('Error'), _('Modify line failed !'))
line_id = order_line_id
- price_line = float(qty)*float(price)
+ price_line = float(qty) * float(price)
return {
'name': product_name,
'product_id': product_id[0],
@@ -1273,12 +1217,11 @@ class product_product(osv.osv):
'disc_controle': fields.boolean('Discount Control'),
}
_defaults = {
- 'disc_controle': lambda *a: True,
+ 'disc_controle': True,
}
product_product()
class stock_picking(osv.osv):
-
_inherit = 'stock.picking'
_columns = {
'pos_order': fields.many2one('pos.order', 'Pos order'),
diff --git a/addons/point_of_sale/posrule_data2.xml b/addons/point_of_sale/point_of_sale_data.xml
similarity index 100%
rename from addons/point_of_sale/posrule_data2.xml
rename to addons/point_of_sale/point_of_sale_data.xml
diff --git a/addons/point_of_sale/pos_demo.xml b/addons/point_of_sale/point_of_sale_demo.xml
similarity index 98%
rename from addons/point_of_sale/pos_demo.xml
rename to addons/point_of_sale/point_of_sale_demo.xml
index 913a2907e03..aa76e3e9976 100644
--- a/addons/point_of_sale/pos_demo.xml
+++ b/addons/point_of_sale/point_of_sale_demo.xml
@@ -1,6 +1,11 @@
+
+
+
+
+
POS/019
POS/019
diff --git a/addons/point_of_sale/pos_report.xml b/addons/point_of_sale/point_of_sale_report.xml
similarity index 100%
rename from addons/point_of_sale/pos_report.xml
rename to addons/point_of_sale/point_of_sale_report.xml
diff --git a/addons/point_of_sale/pos_sequence.xml b/addons/point_of_sale/point_of_sale_sequence.xml
similarity index 100%
rename from addons/point_of_sale/pos_sequence.xml
rename to addons/point_of_sale/point_of_sale_sequence.xml
diff --git a/addons/point_of_sale/pos_view.xml b/addons/point_of_sale/point_of_sale_view.xml
similarity index 100%
rename from addons/point_of_sale/pos_view.xml
rename to addons/point_of_sale/point_of_sale_view.xml
diff --git a/addons/point_of_sale/pos_workflow.xml b/addons/point_of_sale/point_of_sale_workflow.xml
similarity index 100%
rename from addons/point_of_sale/pos_workflow.xml
rename to addons/point_of_sale/point_of_sale_workflow.xml
diff --git a/addons/point_of_sale/test/pos_report.yml b/addons/point_of_sale/test/point_of_sale_report.yml
similarity index 99%
rename from addons/point_of_sale/test/pos_report.yml
rename to addons/point_of_sale/test/point_of_sale_report.yml
index 7eeea10bd1a..d058c8fd691 100644
--- a/addons/point_of_sale/test/pos_report.yml
+++ b/addons/point_of_sale/test/point_of_sale_report.yml
@@ -88,7 +88,7 @@
- name: statement
date: "2010-10-13"
type: customer
- account_id: account_account_sales0
+ account_id: account_pos_account_sales
amount: 100
partner_id: base.res_partner_agrolait
period_id: account.period_5
diff --git a/addons/point_of_sale/test/pos_test.yml b/addons/point_of_sale/test/point_of_sale_test.yml
similarity index 86%
rename from addons/point_of_sale/test/pos_test.yml
rename to addons/point_of_sale/test/point_of_sale_test.yml
index 6baffce34f4..347ea961c8f 100644
--- a/addons/point_of_sale/test/pos_test.yml
+++ b/addons/point_of_sale/test/point_of_sale_test.yml
@@ -3,42 +3,42 @@
-
I configure all details for the Customer, Salesman and Product, Account.
--
+-
I create View Account Type.
--
+-
!record {model: account.account.type, id: account_account_type_view0}:
close_method: none
code: View
name: View
sign: 1
--
+-
I create Income Account Type.
--
+-
!record {model: account.account.type, id: account_account_type_income0}:
close_method: unreconciled
code: Income
name: Income
sign: 1
--
+-
I create Expense Account Type.
--
+-
!record {model: account.account.type, id: account_account_type_expense0}:
close_method: unreconciled
code: Expense
name: Expense
sign: 1
--
+-
I create Cash Account Type.
--
+-
!record {model: account.account.type, id: account_account_type_cash0}:
close_method: balance
code: Cash
name: Cash
sign: 1
--
+-
I create Minimal Chart Account.
--
- !record {model: account.account, id: account_account_minimalchart0}:
+-
+ !record {model: account.account, id: account_pos_account_minimalchart}:
code: '0'
company_id: base.main_company
currency_mode: current
@@ -47,188 +47,188 @@
parent_right: 12
type: view
user_type: account_account_type_view0
--
+-
I create Payable Account.
--
- !record {model: account.account, id: account_account_payable1}:
+-
+ !record {model: account.account, id: account_pos_account_payable}:
code: AP
company_id: base.main_company
currency_mode: current
name: Payable
- parent_id: account_account_minimalchart0
+ parent_id: account_pos_account_minimalchart
parent_left: 2
parent_right: 3
reconcile: true
type: payable
user_type: account_account_type_expense0
--
+-
I create Receivable Account.
--
- !record {model: account.account, id: account_account_receivable0}:
+-
+ !record {model: account.account, id: account_pos_account_receivable}:
code: AR
company_id: base.main_company
currency_mode: current
name: Receivable
- parent_id: account_account_minimalchart0
+ parent_id: account_pos_account_minimalchart
parent_left: 4
parent_right: 5
reconcile: true
type: receivable
user_type: account_account_type_income0
--
+-
I create Cash Account.
--
- !record {model: account.account, id: account_account_cash0}:
+-
+ !record {model: account.account, id: account_pos_account_cash}:
code: C
company_id: base.main_company
currency_mode: current
name: Cash
- parent_id: account_account_minimalchart0
+ parent_id: account_pos_account_minimalchart
parent_left: 6
parent_right: 7
type: other
user_type: account_account_type_cash0
--
+-
I create Purchases Account.
--
- !record {model: account.account, id: account_account_purchases0}:
+-
+ !record {model: account.account, id: account_pos_account_purchases}:
code: P
company_id: base.main_company
currency_mode: current
name: Purchases
- parent_id: account_account_minimalchart0
+ parent_id: account_pos_account_minimalchart
parent_left: 8
parent_right: 9
type: other
user_type: account_account_type_expense0
--
+-
I create Sales Account.
--
- !record {model: account.account, id: account_account_sales0}:
+-
+ !record {model: account.account, id: account_pos_account_sales}:
code: Sale
company_id: base.main_company
currency_mode: current
name: Sales
- parent_id: account_account_minimalchart0
+ parent_id: account_pos_account_minimalchart
parent_left: 10
parent_right: 11
type: other
user_type: account_account_type_income0
--
+-
I create Purchase Journal.
--
- !record {model: account.journal, id: account_journal_purchasejournal0}:
+-
+ !record {model: account.journal, id: account_pos_account_journal_purchasejournal}:
code: PUJ
company_id: base.main_company
- default_credit_account_id: account_account_purchases0
- default_debit_account_id: account_account_purchases0
+ default_credit_account_id: account_pos_account_purchases
+ default_debit_account_id: account_pos_account_purchases
name: Purchase Journal
sequence_id: account.sequence_purchase_journal
type: purchase
view_id: account.account_journal_view
--
+-
I create Sale Journal.
--
- !record {model: account.journal, id: account_journal_salejournal0}:
+-
+ !record {model: account.journal, id: account_pos_account_journal_salejournal}:
code: SAJ
company_id: base.main_company
- default_credit_account_id: account_account_sales0
- default_debit_account_id: account_account_sales0
+ default_credit_account_id: account_pos_account_sales
+ default_debit_account_id: account_pos_account_sales
name: Sale Journal
sequence_id: account.sequence_sale_journal
type: sale
view_id: account.account_journal_view
--
+-
I create Bank Journal.
--
- !record {model: account.journal, id: account_journal_bankjournal0}:
+-
+ !record {model: account.journal, id: account_pos_account_journal_bankjournal}:
code: BNK
company_id: base.main_company
- default_credit_account_id: account_account_cash0
- default_debit_account_id: account_account_cash0
+ default_credit_account_id: account_pos_account_cash
+ default_debit_account_id: account_pos_account_cash
name: Bank Journal
sequence_id: account.sequence_journal
type: cash
view_id: account.account_journal_bank_view
--
+-
I create property for account payable.
--
+-
!record {model: ir.property, id: ir_property_propertyaccountexpensecateg0}:
company_id: base.main_company
fields_id: account.field_res_partner_property_account_payable
name: property_account_expense_categ
value_reference: account.account,5
--
+-
I create property for account receivable.
--
+-
!record {model: ir.property, id: ir_property_propertyaccountincomecateg0}:
company_id: base.main_company
fields_id: account.field_res_partner_property_account_receivable
name: property_account_income_categ
value_reference: account.account,6
--
+-
I create Partner category Customers.
--
+-
!record {model: res.partner.category, id: res_partner_category_customers0}:
name: Customers
-
I create partner
--
+-
!record {model: res.partner, id: res_partner_cleartrail0}:
category_id:
- res_partner_category_customers0
name: Cleartrail
--
+-
I create partner address.
--
+-
!record {model: res.partner.address, id: res_partner_address_1}:
partner_id: res_partner_cleartrail0
street: onam plaza, 14 B palasia A B Road
type: contact
--
+-
I create partner invoice address.
--
+-
!record {model: res.partner.address, id: res_partner_address_2}:
partner_id: res_partner_cleartrail0
type: invoice
--
+-
I create partner delivery address.
--
+-
!record {model: res.partner.address, id: res_partner_address_3}:
partner_id: res_partner_cleartrail0
street: sangam house 15 B palasia, A B Road
type: delivery
-
- I create product category.
--
+ I create product category.
+-
!record {model: product.category, id: product_category_allproductssellable0}:
name: Mobile Products Sellable
-
I create partner.
--
+-
!record {model: res.partner, id: res_partner_microlinktechnologies0}:
address:
- street: Kailash Vaibhav, Parksite
name: Micro Link Technologies
- property_account_payable: account_account_payable1
- property_account_receivable: account_account_receivable0
- supplier: true
+ property_account_payable: account_pos_account_payable
+ property_account_receivable: account_pos_account_receivable
+ supplier: true
-
I create partner address .
--
+-
!record {model: res.partner.address, id: res_partner_address_0}:
country_id: base.in
partner_id: res_partner_microlinktechnologies0
street: Ash House, Ash Road
title: base.res_partner_title_miss
--
+-
I create product category .
--
+-
!record {model: product.category, id: product_category_services0}:
name: Mobile Services
--
+-
I create product template .
--
+-
!record {model: product.template, id: product_template_lgviewtysmart0}:
categ_id: product_category_allproductssellable0
cost_method: standard
@@ -241,9 +241,9 @@
type: product
uom_id: product.product_uom_unit
uom_po_id: product.product_uom_unit
--
+-
I create product LG Viewty Smart.
--
+-
!record {model: product.product, id: product_product_lgviewtysmart0}:
categ_id: product_category_allproductssellable0
cost_method: standard
@@ -251,22 +251,22 @@
mes_type: fixed
name: LG Viewty Smart
procure_method: make_to_order
- property_account_expense: account_account_payable1
- property_account_income: account_account_receivable0
+ property_account_expense: account_pos_account_payable
+ property_account_income: account_pos_account_receivable
seller_delay: '1'
standard_price: 160.0
supply_method: produce
type: product
uom_id: product.product_uom_unit
uom_po_id: product.product_uom_unit
--
- I create product category .
+-
+ I create product category .
-
!record {model: product.category, id: product_category_computer0}:
name: Computer
--
+-
I create product HP Pavilion Desktop PCs
--
+-
!record {model: product.product, id: product_product_hppaviliondesktoppcs0}:
categ_id: product_category_computer0
cost_method: standard
@@ -282,9 +282,9 @@
type: product
uom_id: product.product_uom_unit
uom_po_id: product.product_uom_unit
- property_account_expense: account_account_payable1
- property_account_income: account_account_receivable0
--
+ property_account_expense: account_pos_account_payable
+ property_account_income: account_pos_account_receivable
+-
I create New Order by adding the details of Salesman and "Product" as LG Viewty Smart Quantity as 10.
-
!record {model: pos.order, id: pos_order_pos0}:
diff --git a/addons/point_of_sale/wizard/all_closed_cashbox_of_the_day.py b/addons/point_of_sale/wizard/all_closed_cashbox_of_the_day.py
index 58f78902a14..e38d1c1aa03 100644
--- a/addons/point_of_sale/wizard/all_closed_cashbox_of_the_day.py
+++ b/addons/point_of_sale/wizard/all_closed_cashbox_of_the_day.py
@@ -19,40 +19,30 @@
#
##############################################################################
-import netsvc
-from osv import osv,fields
-from tools.translate import _
-import time
+from osv import osv
class all_closed_cashbox_of_the_day(osv.osv_memory):
_name = 'all.closed.cashbox.of.the.day'
_description = 'All closed cashbox of the day'
- _columns = {
-
- }
-
def print_report(self, cr, uid, ids, context=None):
-
"""
To get the date and print the report
-
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param context: A standard dictionary
@return : retrun report
"""
- datas = {'ids' : context.get('active_ids',[])}
+ datas = {'ids': context.get('active_ids', [])}
res = {}
datas['form'] = res
-
return {
- 'type' : 'ir.actions.report.xml',
- 'report_name':'all.closed.cashbox.of.the.day',
- 'datas' : datas,
+ 'type': 'ir.actions.report.xml',
+ 'report_name': 'all.closed.cashbox.of.the.day',
+ 'datas': datas,
}
all_closed_cashbox_of_the_day()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/point_of_sale/wizard/pos_add_product.py b/addons/point_of_sale/wizard/pos_add_product.py
index 5735d2976a4..601c3d3f305 100644
--- a/addons/point_of_sale/wizard/pos_add_product.py
+++ b/addons/point_of_sale/wizard/pos_add_product.py
@@ -32,10 +32,10 @@ class add_product(osv.osv_memory):
'quantity': fields.float('Quantity', required=True),
}
_defaults = {
- 'quantity': lambda *a: 1,
+ 'quantity': 1,
}
- def select_product(self, cr, uid, ids, context):
+ def select_product(self, cr, uid, ids, context=None):
"""
To get the product and quantity and add in order .
@param self: The object pointer.
@@ -44,13 +44,14 @@ class add_product(osv.osv_memory):
@param context: A standard dictionary
@return : Return the add product form again for adding more product
"""
+ if context is None:
+ context = {}
this = self.browse(cr, uid, ids[0], context=context)
record_id = context and context.get('active_id', False)
assert record_id, _('Active ID is not found')
if record_id:
order_obj = self.pool.get('pos.order')
order_obj.add_product(cr, uid, record_id, this.product_id.id, this.quantity, context=context)
-
return {
'name': _('Add Product'),
'view_type': 'form',
@@ -61,34 +62,36 @@ class add_product(osv.osv_memory):
'views': False,
'type': 'ir.actions.act_window',
}
- def close_action(self, cr, uid, ids, context):
+
+ def close_action(self, cr, uid, ids, context=None):
"""
To get the product and Make the payment .
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param context: A standard dictionary
- @return : Return the Make Payment
+ @return : Return the Make Payment
"""
-
+ if context is None:
+ context = {}
record_id = context and context.get('active_id', False)
order_obj= self.pool.get('pos.order')
- obj=order_obj.browse(cr, uid, record_id)
- order_obj.write(cr, uid, [record_id], {'state':'done'})
+ obj = order_obj.browse(cr, uid, record_id, context=context)
+ order_obj.write(cr, uid, [record_id], {'state': 'done'}, context=context)
if obj.amount_total != obj.amount_paid:
return {
- 'name': _('Make Payment'),
- 'context ':context and context.get('active_id', False),
- 'view_type': 'form',
- 'view_mode': 'form',
- 'res_model': 'pos.make.payment',
- 'view_id': False,
- 'target': 'new',
- 'views': False,
- 'type': 'ir.actions.act_window',
-
+ 'name': _('Make Payment'),
+ 'context': context and context.get('active_id', False),
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'pos.make.payment',
+ 'view_id': False,
+ 'target': 'new',
+ 'views': False,
+ 'type': 'ir.actions.act_window',
}
- return {}
+ return {}
+
add_product()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/point_of_sale/wizard/pos_box_entries.py b/addons/point_of_sale/wizard/pos_box_entries.py
index 103e49be62d..243cbc02c7d 100644
--- a/addons/point_of_sale/wizard/pos_box_entries.py
+++ b/addons/point_of_sale/wizard/pos_box_entries.py
@@ -19,30 +19,31 @@
#
##############################################################################
-from osv import osv, fields
import time
+
+from osv import osv, fields
from tools.translate import _
-def get_journal(self, cr, uid, context):
+def get_journal(self, cr, uid, context=None):
"""
- Make the selection list of Cash Journal .
- @param self: The object pointer.
- @param cr: A database cursor
- @param uid: ID of the user currently logged in
- @param context: A standard dictionary
- @return :Return the list of journal
+ Make the selection list of Cash Journal .
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param context: A standard dictionary
+ @return :Return the list of journal
"""
- obj = self.pool.get('account.journal')
+ journal_obj = self.pool.get('account.journal')
statement_obj = self.pool.get('account.bank.statement')
- cr.execute("SELECT DISTINCT journal_id from pos_journal_users where user_id=%s order by journal_id", (uid,))
+ cr.execute("SELECT DISTINCT journal_id FROM pos_journal_users WHERE user_id = %s ORDER BY journal_id", (uid, ))
j_ids = map(lambda x1: x1[0], cr.fetchall())
- ids = obj.search(cr, uid, [('type', '=', 'cash'), ('id', 'in', j_ids)])
- obj_ids= statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', 'in', ids)])
- res_obj = obj.read(cr, uid, ids, ['journal_id'], context)
- res_obj = [(r1['id'])for r1 in res_obj]
- res = statement_obj.read(cr, uid, obj_ids, ['journal_id'], context)
+ ids = journal_obj.search(cr, uid, [('type', '=', 'cash'), ('id', 'in', j_ids)], context=context)
+ obj_ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', 'in', ids)], context=context)
+ res_obj = journal_obj.read(cr, uid, ids, ['journal_id'], context=context)
+ res_obj = [(r1['id']) for r1 in res_obj]
+ res = statement_obj.read(cr, uid, obj_ids, ['journal_id'], context=context)
res = [(r['journal_id']) for r in res]
res.insert(0, ('', ''))
return res
@@ -51,10 +52,7 @@ class pos_box_entries(osv.osv_memory):
_name = 'pos.box.entries'
_description = 'Pos Box Entries'
-
-
- def _get_income_product(self, cr, uid, context):
-
+ def _get_income_product(self, cr, uid, context=None):
"""
Make the selection list of purchasing products.
@param self: The object pointer.
@@ -63,10 +61,10 @@ class pos_box_entries(osv.osv_memory):
@param context: A standard dictionary
@return :Return of operation of product
"""
- obj = self.pool.get('product.product')
- ids = obj.search(cr, uid, [('income_pdt', '=', True)])
- res = obj.read(cr, uid, ids, ['id', 'name'], context)
- res = [(r['id'],r['name']) for r in res]
+ product_obj = self.pool.get('product.product')
+ ids = product_obj.search(cr, uid, [('income_pdt', '=', True)], context=context)
+ res = product_obj.read(cr, uid, ids, ['id', 'name'], context=context)
+ res = [(r['id'], r['name']) for r in res]
res.insert(0, ('', ''))
return res
@@ -74,17 +72,17 @@ class pos_box_entries(osv.osv_memory):
_columns = {
'name': fields.char('Description', size=32, required=True),
- 'journal_id': fields.selection(get_journal, "Register", required=True),
- 'product_id': fields.selection(_get_income_product, "Operation", required=True),
+ 'journal_id': fields.selection(get_journal, 'Register', required=True),
+ 'product_id': fields.selection(_get_income_product, 'Operation', required=True),
'amount': fields.float('Amount', digits=(16, 2)),
'ref': fields.char('Ref', size=32),
}
_defaults = {
- 'journal_id': lambda *a: 1,
- 'product_id': lambda *a: 1,
+ 'journal_id': 1,
+ 'product_id': 1,
}
- def get_in(self, cr, uid, ids, context):
+ def get_in(self, cr, uid, ids, context=None):
"""
Create the entry of statement in journal.
@param self: The object pointer.
@@ -94,14 +92,13 @@ class pos_box_entries(osv.osv_memory):
@return :Return of operation of product
"""
statement_obj = self.pool.get('account.bank.statement')
- product_obj = self.pool.get('product.template')
res_obj = self.pool.get('res.users')
product_obj = self.pool.get('product.product')
bank_statement = self.pool.get('account.bank.statement.line')
- for data in self.read(cr, uid, ids):
- args = {}
- curr_company = res_obj.browse(cr, uid, uid).company_id.id
- statement_id = statement_obj.search(cr, uid, [('journal_id', '=', data['journal_id']), ('company_id', '=', curr_company), ('user_id', '=', uid), ('state', '=', 'open')])
+ for data in self.read(cr, uid, ids, context=context):
+ vals = {}
+ curr_company = res_obj.browse(cr, uid, uid, context=context).company_id.id
+ statement_id = statement_obj.search(cr, uid, [('journal_id', '=', data['journal_id']), ('company_id', '=', curr_company), ('user_id', '=', uid), ('state', '=', 'open')], context=context)
if not statement_id:
raise osv.except_osv(_('Error !'), _('You have to open at least one cashbox'))
@@ -116,22 +113,20 @@ class pos_box_entries(osv.osv_memory):
'journal_id': data['journal_id'],
'company_id': curr_company,
'user_id': uid,
- })
+ }, context=context)
- args['statement_id'] = statement_id
- args['journal_id'] = data['journal_id']
+ vals['statement_id'] = statement_id
+ valss['journal_id'] = data['journal_id']
if acc_id:
- args['account_id'] = acc_id.id
- args['amount'] = data['amount'] or 0.0
- args['ref'] = "%s" % (data['ref'] or '')
- args['name'] = "%s: %s " % (product_obj.browse(cr, uid, data['product_id']).name, data['name'].decode('utf8'))
- address_u = res_obj.browse(cr, uid, uid).address_id
+ vals['account_id'] = acc_id.id
+ vals['amount'] = data['amount'] or 0.0
+ vals['ref'] = "%s" % (data['ref'] or '')
+ vals['name'] = "%s: %s " % (product_obj.browse(cr, uid, data['product_id'], context=context).name, data['name'].decode('utf8'))
+ address_u = res_obj.browse(cr, uid, uid, context=context).address_id
if address_u:
- partner_id = address_u.partner_id and address_u.partner_id.id or None
- args['partner_id'] = partner_id
- bank_statement.create(cr, uid, args)
-
- return {}
+ vals['partner_id'] = address_u.partner_id and address_u.partner_id.id or None
+ bank_statement.create(cr, uid, vals, context=context)
+ return {}
pos_box_entries()
diff --git a/addons/point_of_sale/wizard/pos_box_out.py b/addons/point_of_sale/wizard/pos_box_out.py
index e4aebe2cc1d..d2eb7b62509 100644
--- a/addons/point_of_sale/wizard/pos_box_out.py
+++ b/addons/point_of_sale/wizard/pos_box_out.py
@@ -19,20 +19,19 @@
#
##############################################################################
-from osv import osv, fields
import time
-from tools.translate import _
from datetime import datetime
from dateutil.relativedelta import relativedelta
-import pos_box_entries
+from osv import osv, fields
+from tools.translate import _
+import pos_box_entries
class pos_box_out(osv.osv_memory):
_name = 'pos.box.out'
_description = 'Pos Box Out'
- def _get_expense_product(self, cr, uid, context):
-
+ def _get_expense_product(self, cr, uid, context=None):
"""
Make the selection list of expense product.
@param self: The object pointer.
@@ -41,26 +40,26 @@ class pos_box_out(osv.osv_memory):
@param context: A standard dictionary
@return :Return of operation of product
"""
- obj = self.pool.get('product.product')
- company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
- ids = obj.search(cr, uid, ['&', ('expense_pdt', '=', True), '|', ('company_id', '=', company_id), ('company_id', '=', None)])
- res = obj.read(cr, uid, ids, ['id', 'name'], context)
+ product_obj = self.pool.get('product.product')
+ company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
+ ids = product_obj.search(cr, uid, ['&', ('expense_pdt', '=', True), '|', ('company_id', '=', company_id), ('company_id', '=', None)], context=context)
+ res = product_obj.read(cr, uid, ids, ['id', 'name'], context=context)
res = [(r['id'], r['name']) for r in res]
res.insert(0, ('', ''))
return res
_columns = {
'name': fields.char('Description', size=32, required=True),
- 'journal_id': fields.selection(pos_box_entries.get_journal, "Register", required=True),
- 'product_id': fields.selection(_get_expense_product, "Operation", required=True),
+ 'journal_id': fields.selection(pos_box_entries.get_journal, 'Register', required=True),
+ 'product_id': fields.selection(_get_expense_product, 'Operation', required=True),
'amount': fields.float('Amount', digits=(16, 2)),
'ref': fields.char('Ref', size=32),
}
_defaults = {
- 'journal_id': lambda *a: 1,
- 'product_id': lambda *a: 1,
+ 'journal_id': 1,
+ 'product_id': 1,
}
- def get_out(self, cr, uid, ids, context):
+ def get_out(self, cr, uid, ids, context=None):
"""
Create the entries in the CashBox .
@@ -70,34 +69,34 @@ class pos_box_out(osv.osv_memory):
@param context: A standard dictionary
@return :Return of operation of product
"""
- args = {}
+ vals = {}
statement_obj = self.pool.get('account.bank.statement')
statement_line_obj = self.pool.get('account.bank.statement.line')
product_obj = self.pool.get('product.template')
productp_obj = self.pool.get('product.product')
res_obj = self.pool.get('res.users')
- for data in self.read(cr, uid, ids):
- curr_company = res_obj.browse(cr, uid, uid).company_id.id
- statement_id = statement_obj.search(cr, uid, [('journal_id', '=', data['journal_id']), ('company_id', '=', curr_company), ('user_id', '=', uid), ('state', '=', 'open')])
+ for data in self.read(cr, uid, ids, context=context):
+ curr_company = res_obj.browse(cr, uid, uid, context=context).company_id.id
+ statement_id = statement_obj.search(cr, uid, [('journal_id', '=', data['journal_id']), ('company_id', '=', curr_company), ('user_id', '=', uid), ('state', '=', 'open')], context=context)
monday = (datetime.today() + relativedelta(weekday=0)).strftime('%Y-%m-%d')
sunday = (datetime.today() + relativedelta(weekday=6)).strftime('%Y-%m-%d')
- done_statmt = statement_obj.search(cr, uid, [('date', '>=', monday+' 00:00:00'), ('date', '<=', sunday+' 23:59:59'), ('journal_id', '=', data['journal_id']), ('company_id', '=', curr_company), ('user_id', '=', uid)])
- stat_done = statement_obj.browse(cr, uid, done_statmt)
- address_u = res_obj.browse(cr, uid, uid).address_id
+ done_statmt = statement_obj.search(cr, uid, [('date', '>=', monday+' 00:00:00'), ('date', '<=', sunday+' 23:59:59'), ('journal_id', '=', data['journal_id']), ('company_id', '=', curr_company), ('user_id', '=', uid)], context=context)
+ stat_done = statement_obj.browse(cr, uid, done_statmt, context=context)
+ address_u = res_obj.browse(cr, uid, uid, context=context).address_id
am = 0.0
- amount_check = productp_obj.browse(cr, uid, data['product_id']).am_out or False
+ amount_check = productp_obj.browse(cr, uid, data['product_id'], context=context).am_out or False
for st in stat_done:
for s in st.line_ids:
if address_u and s.partner_id == address_u.partner_id and s.am_out:
am += s.amount
- if (-data['amount'] or 0.0) + am < -(res_obj.browse(cr, uid, uid).company_id.max_diff or 0.0) and amount_check:
+ if (-data['amount'] or 0.0) + am < -(res_obj.browse(cr, uid, uid, context=context).company_id.max_diff or 0.0) and amount_check:
val = (res_obj.browse(cr, uid, uid).company_id.max_diff or 0.0) + am
raise osv.except_osv(_('Error !'), _('The maximum value you can still withdraw is exceeded. \n Remaining value is equal to %d ')%(val))
- acc_id = product_obj.browse(cr, uid, data['product_id']).property_account_income
+ acc_id = product_obj.browse(cr, uid, data['product_id'], context=context).property_account_income
if not acc_id:
- raise osv.except_osv(_('Error !'), _('please check that account is set to %s')%(product_obj.browse(cr, uid, data['product_id']).name))
+ raise osv.except_osv(_('Error !'), _('please check that account is set to %s')%(product_obj.browse(cr, uid, data['product_id'], context=context).name))
if not statement_id:
raise osv.except_osv(_('Error !'), _('You have to open at least one cashbox'))
if statement_id:
@@ -108,24 +107,23 @@ class pos_box_out(osv.osv_memory):
'journal_id': data['journal_id'],
'company_id': curr_company,
'user_id': uid,
- })
- args['statement_id'] = statement_id
- args['journal_id'] = data['journal_id']
+ }, context=context)
+ vals['statement_id'] = statement_id
+ vals['journal_id'] = data['journal_id']
if acc_id:
- args['account_id'] = acc_id.id
+ vals['account_id'] = acc_id.id
amount = data['amount'] or 0.0
if data['amount'] > 0:
amount = -data['amount']
- args['amount'] = amount
- if productp_obj.browse(cr, uid, data['product_id']).am_out:
- args['am_out'] = True
- args['ref'] = data['ref'] or ''
- args['name'] = "%s: %s " % (product_obj.browse(cr, uid, data['product_id']).name, data['name'].decode('utf8'))
- address_u = res_obj.browse(cr, uid, uid).address_id
+ vals['amount'] = amount
+ if productp_obj.browse(cr, uid, data['product_id'], context=context).am_out:
+ vals['am_out'] = True
+ vals['ref'] = data['ref'] or ''
+ vals['name'] = "%s: %s " % (product_obj.browse(cr, uid, data['product_id'], context=context).name, data['name'].decode('utf8'))
+ address_u = res_obj.browse(cr, uid, uid, context=context).address_id
if address_u:
- partner_id = address_u.partner_id and address_u.partner_id.id or None
- args['partner_id'] = partner_id
- statement_line_id = statement_line_obj.create(cr, uid, args)
+ vals['partner_id'] = address_u.partner_id and address_u.partner_id.id or None
+ statement_line_id = statement_line_obj.create(cr, uid, vals, context=context)
return {}
pos_box_out()
diff --git a/addons/point_of_sale/wizard/pos_close_statement.py b/addons/point_of_sale/wizard/pos_close_statement.py
index 82e47a2caa3..02c82a3cf98 100644
--- a/addons/point_of_sale/wizard/pos_close_statement.py
+++ b/addons/point_of_sale/wizard/pos_close_statement.py
@@ -26,7 +26,7 @@ class pos_close_statement(osv.osv_memory):
_name = 'pos.close.statement'
_description = 'Close Statements'
- def close_statement(self, cr, uid, ids, context):
+ def close_statement(self, cr, uid, ids, context=None):
"""
Close the statements
@param self: The object pointer.
@@ -39,34 +39,33 @@ class pos_close_statement(osv.osv_memory):
statement_obj = self.pool.get('account.bank.statement')
journal_obj = self.pool.get('account.journal')
cr.execute("SELECT DISTINCT journal_id FROM pos_journal_users "
- "WHERE user_id=%s ORDER BY journal_id", (uid,))
+ "WHERE user_id=%s ORDER BY journal_id", (uid, ))
j_ids = map(lambda x1: x1[0], cr.fetchall())
- journal_ids = journal_obj.search(cr, uid, [('auto_cash', '=', True), ('type', '=', 'cash'), ('id', 'in', j_ids)])
- ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', 'in', journal_ids)])
- for journal in journal_obj.browse(cr, uid, journal_ids):
+ journal_ids = journal_obj.search(cr, uid, [('auto_cash', '=', True), ('type', '=', 'cash'), ('id', 'in', j_ids)], context=context)
+ ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', 'in', journal_ids)], context=context)
+ for journal in journal_obj.browse(cr, uid, journal_ids, context=context):
if not ids:
raise osv.except_osv(_('Message'), _('Registers are already closed.'))
else:
if not journal.check_dtls:
- statement_obj.button_confirm_cash(cr, uid, ids, context)
+ statement_obj.button_confirm_cash(cr, uid, ids, context=context)
- data_obj = self.pool.get('ir.model.data')
- id2 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_tree')
- id3 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_form2')
- result = data_obj._get_id(cr, uid, 'point_of_sale', 'view_pos_confirm_cash_statement_filter')
+ id2 = mod_obj._get_id(cr, uid, 'account', 'view_bank_statement_tree')
+ id3 = mod_obj._get_id(cr, uid, 'account', 'view_bank_statement_form2')
+ result = mod_obj._get_id(cr, uid, 'point_of_sale', 'view_pos_confirm_cash_statement_filter')
search_id = mod_obj.read(cr, uid, result, ['res_id'], context=context)
if id2:
- id2 = data_obj.browse(cr, uid, id2, context=context).res_id
+ id2 = mod_obj.browse(cr, uid, id2, context=context).res_id
if id3:
- id3 = data_obj.browse(cr, uid, id3, context=context).res_id
+ id3 = mod_obj.browse(cr, uid, id3, context=context).res_id
return {
- 'domain': "[('id','in'," + str(ids) + ")]",
+ 'domain': "[('id', 'in', " + str(ids) + ")]",
'name': 'Close Statements',
'view_type': 'form',
- 'view_mode': 'tree,form',
+ 'view_mode': 'tree, form',
'search_view_id': search_id['res_id'],
'res_model': 'account.bank.statement',
- 'views': [(id2, 'tree'),(id3, 'form')],
+ 'views': [(id2, 'tree'), (id3, 'form')],
'type': 'ir.actions.act_window'
}
diff --git a/addons/point_of_sale/wizard/pos_confirm.py b/addons/point_of_sale/wizard/pos_confirm.py
index de293eaebc7..f4c53d66297 100644
--- a/addons/point_of_sale/wizard/pos_confirm.py
+++ b/addons/point_of_sale/wizard/pos_confirm.py
@@ -28,7 +28,7 @@ class pos_confirm(osv.osv_memory):
_name = 'pos.confirm'
_description = 'Point of Sale Confirm'
- def action_confirm(self, cr, uid, ids, context):
+ def action_confirm(self, cr, uid, ids, context=None):
"""
Confirm the order and close the sales.
@param self: The object pointer.
@@ -37,7 +37,8 @@ class pos_confirm(osv.osv_memory):
@param context: A standard dictionary
@return :Blank dictionary
"""
-
+ if context is None:
+ context = {}
record_id = context and context.get('active_id', False)
if record_id:
if isinstance(record_id, (int, long)):
@@ -47,7 +48,7 @@ class pos_confirm(osv.osv_memory):
for order_id in order_obj.browse(cr, uid, record_id, context=context):
if order_id.state == 'paid':
- order_obj.write(cr, uid, [order_id.id], {'journal_entry': True})
+ order_obj.write(cr, uid, [order_id.id], {'journal_entry': True}, context=context)
order_obj.create_account_move(cr, uid, [order_id.id], context=context)
wf_service = netsvc.LocalService("workflow")
diff --git a/addons/point_of_sale/wizard/pos_details.py b/addons/point_of_sale/wizard/pos_details.py
index 22d29b469fa..2e272826b4f 100644
--- a/addons/point_of_sale/wizard/pos_details.py
+++ b/addons/point_of_sale/wizard/pos_details.py
@@ -19,9 +19,10 @@
#
##############################################################################
+import time
+
from osv import osv, fields
from tools.translate import _
-import time
class pos_details(osv.osv_memory):
@@ -33,11 +34,11 @@ class pos_details(osv.osv_memory):
'date_end': fields.date('Date End', required=True)
}
_defaults = {
- 'date_start': lambda *a: time.strftime('%Y-%m-%d'),
- 'date_end': lambda *a: time.strftime('%Y-%m-%d'),
+ 'date_start': time.strftime('%Y-%m-%d'),
+ 'date_end': time.strftime('%Y-%m-%d'),
}
- def print_report(self, cr, uid, ids, context={}):
+ def print_report(self, cr, uid, ids, context=None):
"""
To get the date and print the report
@param self: The object pointer.
@@ -46,12 +47,12 @@ class pos_details(osv.osv_memory):
@param context: A standard dictionary
@return : retrun report
"""
-
+ if context is None:
+ context = {}
datas = {'ids': context.get('active_ids', [])}
- res = self.read(cr, uid, ids, ['date_start', 'date_end'], context)
+ res = self.read(cr, uid, ids, ['date_start', 'date_end'], context=context)
res = res and res[0] or {}
datas['form'] = res
-
return {
'type': 'ir.actions.report.xml',
'report_name': 'pos.details',
diff --git a/addons/point_of_sale/wizard/pos_discount.py b/addons/point_of_sale/wizard/pos_discount.py
index 375b7dc20d4..d92a545a4ab 100644
--- a/addons/point_of_sale/wizard/pos_discount.py
+++ b/addons/point_of_sale/wizard/pos_discount.py
@@ -32,7 +32,7 @@ class pos_discount(osv.osv_memory):
'discount_notes': fields.char('Discount Notes', size= 128, required=True),
}
_defaults = {
- 'discount': lambda *a: 5,
+ 'discount': 5,
}
@@ -47,11 +47,11 @@ class pos_discount(osv.osv_memory):
"""
res = super(pos_discount, self).view_init(cr, uid, fields_list, context=context)
record_id = context and context.get('active_id', False) or False
- order = self.pool.get('pos.order').browse(cr, uid, record_id)
+ order = self.pool.get('pos.order').browse(cr, uid, record_id, context=context)
if not order.lines:
raise osv.except_osv('Error!','No Order Lines ')
True
- def apply_discount(self, cr, uid, ids, context):
+ def apply_discount(self, cr, uid, ids, context=None):
"""
To give the discount of product and check the.
@@ -61,16 +61,16 @@ class pos_discount(osv.osv_memory):
@param context: A standard dictionary
@return : nothing
"""
+ order_ref = self.pool.get('pos.order')
+ order_line_ref = self.pool.get('pos.order.line')
+ if context is None:
+ context = {}
this = self.browse(cr, uid, ids[0], context=context)
record_id = context and context.get('active_id', False)
if isinstance(record_id, (int, long)):
record_id = [record_id]
- order_ref = self.pool.get('pos.order')
- order_line_ref = self.pool.get('pos.order.line')
-
for order in order_ref.browse(cr, uid, record_id, context=context):
-
for line in order.lines:
company_discount = order.company_id.company_discount
applied_discount = this.discount
@@ -81,10 +81,7 @@ class pos_discount(osv.osv_memory):
notice = 'Minimum Discount'
else:
notice = this.discount_notes
-
- res_new = {
- }
-
+ res_new = {}
if this.discount <= company_discount:
res_new = {
'discount': this.discount,
diff --git a/addons/point_of_sale/wizard/pos_get_sale.py b/addons/point_of_sale/wizard/pos_get_sale.py
index 1cc9675bf84..48bd89bce7f 100644
--- a/addons/point_of_sale/wizard/pos_get_sale.py
+++ b/addons/point_of_sale/wizard/pos_get_sale.py
@@ -28,10 +28,10 @@ class pos_get_sale(osv.osv_memory):
_description = 'Get From Sale'
_columns = {
- 'picking_id': fields.many2one('stock.picking', 'Sale Order', domain=[('state', 'in', ('assigned', 'confirmed')), ('type', '=', 'out')], context="{'contact_display':'partner'}", required=True),
+ 'picking_id': fields.many2one('stock.picking', 'Sale Order', domain=[('state', 'in', ('assigned', 'confirmed')), ('type', '=', 'out')], context="{'contact_display': 'partner'}", required=True),
}
- def sale_complete(self, cr, uid, ids, context):
+ def sale_complete(self, cr, uid, ids, context=None):
"""
Select the picking order and add the in Point of sale order
@param self: The object pointer.
@@ -40,29 +40,29 @@ class pos_get_sale(osv.osv_memory):
@param context: A standard dictionary
@return : nothing
"""
- this = self.browse(cr, uid, ids[0], context=context)
- record_id = context and context.get('active_id', False)
-
proxy_pos = self.pool.get('pos.order')
proxy_pick = self.pool.get('stock.picking')
proxy_order_line = self.pool.get('pos.order.line')
+ if context is None:
+ context = {}
+ this = self.browse(cr, uid, ids[0], context=context)
+ record_id = context and context.get('active_id', False)
if record_id:
- order = proxy_pos.browse(cr, uid, record_id, context)
-
+ order = proxy_pos.browse(cr, uid, record_id, context=context)
if order.state in ('paid', 'invoiced'):
raise osv.except_osv(_('UserError '), _("You can't modify this order. It has already been paid"))
- for pick in proxy_pick.browse(cr, uid, [this.picking_id.id], context):
+ for pick in proxy_pick.browse(cr, uid, [this.picking_id.id], context=context):
proxy_pos.write(cr, uid, record_id, {
'picking_id': this.picking_id.id,
'partner_id': pick.address_id and pick.address_id.partner_id.id
- })
+ }, context=context)
order = proxy_pick.write(cr, uid, [this.picking_id.id], {
'invoice_state': 'none',
'pos_order': record_id
- })
+ }, context=context)
for line in pick.move_lines:
proxy_order_line.create(cr, uid, {
@@ -72,8 +72,7 @@ class pos_get_sale(osv.osv_memory):
'product_id': line.product_id.id,
'price_unit': line.sale_line_id.price_unit,
'discount': line.sale_line_id.discount,
- })
-
+ }, context=context)
return {}
pos_get_sale()
diff --git a/addons/point_of_sale/wizard/pos_open_statement.py b/addons/point_of_sale/wizard/pos_open_statement.py
index 67c5b125768..9bbed850dfc 100644
--- a/addons/point_of_sale/wizard/pos_open_statement.py
+++ b/addons/point_of_sale/wizard/pos_open_statement.py
@@ -26,7 +26,7 @@ class pos_open_statement(osv.osv_memory):
_name = 'pos.open.statement'
_description = 'Open Statements'
- def open_statement(self, cr, uid, ids, context):
+ def open_statement(self, cr, uid, ids, context=None):
"""
Open the statements
@param self: The object pointer.
@@ -37,20 +37,20 @@ class pos_open_statement(osv.osv_memory):
"""
data = {}
mod_obj = self.pool.get('ir.model.data')
- company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
statement_obj = self.pool.get('account.bank.statement')
sequence_obj = self.pool.get('ir.sequence')
journal_obj = self.pool.get('account.journal')
+ company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
cr.execute("SELECT DISTINCT journal_id FROM pos_journal_users "
- "WHERE user_id=%s ORDER BY journal_id"% (uid,))
+ "WHERE user_id = %s ORDER BY journal_id"% (uid, ))
j_ids = map(lambda x1: x1[0], cr.fetchall())
- journal_ids = journal_obj.search(cr, uid, [('auto_cash', '=', True), ('type', '=', 'cash'), ('id', 'in', j_ids)])
+ journal_ids = journal_obj.search(cr, uid, [('auto_cash', '=', True), ('type', '=', 'cash'), ('id', 'in', j_ids)], context=context)
- for journal in journal_obj.browse(cr, uid, journal_ids):
- ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', '=', journal.id)])
+ for journal in journal_obj.browse(cr, uid, journal_ids, context=context):
+ ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', '=', journal.id)], context=context)
if len(ids):
raise osv.except_osv(_('Message'), _('You can not open a Cashbox for "%s".\nPlease close its related Register.' %(journal.name)))
-
+
number = ''
if journal.sequence_id:
number = sequence_obj.get_id(cr, uid, journal.sequence_id.id)
@@ -62,27 +62,26 @@ class pos_open_statement(osv.osv_memory):
'user_id': uid,
'state': 'draft',
'name': number })
- statement_id = statement_obj.create(cr, uid, data)
+ statement_id = statement_obj.create(cr, uid, data, context=context)
statement_obj.button_open(cr, uid, [statement_id], context)
- data_obj = self.pool.get('ir.model.data')
- id2 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_tree')
- id3 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_form2')
- result = data_obj._get_id(cr, uid, 'point_of_sale', 'view_pos_open_cash_statement_filter')
+ id2 = mod_obj._get_id(cr, uid, 'account', 'view_bank_statement_tree')
+ id3 = mod_obj._get_id(cr, uid, 'account', 'view_bank_statement_form2')
+ result = mod_obj._get_id(cr, uid, 'point_of_sale', 'view_pos_open_cash_statement_filter')
search_id = mod_obj.read(cr, uid, result, ['res_id'], context=context)
if id2:
- id2 = data_obj.browse(cr, uid, id2, context=context).res_id
+ id2 = mod_obj.browse(cr, uid, id2, context=context).res_id
if id3:
- id3 = data_obj.browse(cr, uid, id3, context=context).res_id
+ id3 = mod_obj.browse(cr, uid, id3, context=context).res_id
return {
- 'domain': "[('state','=','open'),('user_id','=',"+ str(uid) +")]",
+ 'domain': "[('state', '=', 'open'),('user_id', '=', "+ str(uid) +")]",
'name': 'Open Statement',
'view_type': 'form',
- 'view_mode': 'tree,form',
+ 'view_mode': 'tree, form',
'search_view_id': search_id['res_id'],
'res_model': 'account.bank.statement',
- 'views': [(id2, 'tree'),(id3, 'form')],
+ 'views': [(id2, 'tree'), (id3, 'form')],
'context': {'search_default_open': 1},
'type': 'ir.actions.act_window'
}
diff --git a/addons/point_of_sale/wizard/pos_payment.py b/addons/point_of_sale/wizard/pos_payment.py
index 1c92ad24132..2d9b1a5d402 100644
--- a/addons/point_of_sale/wizard/pos_payment.py
+++ b/addons/point_of_sale/wizard/pos_payment.py
@@ -19,16 +19,18 @@
#
##############################################################################
-from osv import osv,fields
+import time
+
+from osv import osv, fields
from tools.translate import _
import pos_box_entries
-import time
+
class pos_make_payment(osv.osv_memory):
_name = 'pos.make.payment'
_description = 'Point of Sale Payment'
- def default_get(self, cr, uid, fields, context):
+ def default_get(self, cr, uid, fields, context=None):
"""
To get default values for the object.
@param self: The object pointer.
@@ -38,40 +40,40 @@ class pos_make_payment(osv.osv_memory):
@param context: A standard dictionary
@return: A dictionary which of fields with values.
"""
+ if context is None:
+ context = {}
+ j_obj = self.pool.get('account.journal')
+ order_obj=self.pool.get('pos.order')
res = super(pos_make_payment, self).default_get(cr, uid, fields, context=context)
- active_id = context and context.get('active_id',False)
+ active_id = context and context.get('active_id', False)
if active_id:
- j_obj = self.pool.get('account.journal')
cr.execute("SELECT DISTINCT journal_id FROM pos_journal_users "
- "WHERE user_id=%d ORDER BY journal_id"% (uid,))
+ "WHERE user_id = %d ORDER BY journal_id"% (uid, ))
j_ids = map(lambda x1: x1[0], cr.fetchall())
- journal = j_obj.search(cr, uid, [('type', '=', 'cash'), ('id', 'in', j_ids)])
-
+ journal = j_obj.search(cr, uid, [('type', '=', 'cash'), ('id', 'in', j_ids)], context=context)
journal = journal and journal[0] or False
-
- order_obj=self.pool.get('pos.order')
- order = order_obj.browse(cr, uid, active_id, context)
+ order = order_obj.browse(cr, uid, active_id, context=context)
#get amount to pay
amount = order.amount_total - order.amount_paid
if amount <= 0.0:
context.update({'flag': True})
order_obj.action_paid(cr, uid, [active_id], context)
elif order.amount_paid > 0.0:
- order_obj.write(cr, uid, [active_id], {'state': 'advance'})
+ order_obj.write(cr, uid, [active_id], {'state': 'advance'}, context=context)
invoice_wanted_checked = False
current_date = time.strftime('%Y-%m-%d')
if 'journal' in fields:
- res.update({'journal':journal})
+ res.update({'journal': journal})
if 'amount' in fields:
- res.update({'amount':amount})
+ res.update({'amount': amount})
if 'invoice_wanted' in fields:
- res.update({'invoice_wanted':invoice_wanted_checked})
+ res.update({'invoice_wanted': invoice_wanted_checked})
if 'payment_date' in fields:
- res.update({'payment_date':current_date})
+ res.update({'payment_date': current_date})
if 'payment_name' in fields:
- res.update({'payment_name':'Payment'})
+ res.update({'payment_name': 'Payment'})
if 'partner_id' in fields:
res.update({'partner_id': order.partner_id.id or False})
if 'pricelist_id' in fields:
@@ -82,7 +84,7 @@ class pos_make_payment(osv.osv_memory):
super(pos_make_payment, self).view_init(cr, uid, fields_list, context=context)
active_id = context and context.get('active_id', False) or False
if active_id:
- order = self.pool.get('pos.order').browse(cr, uid, active_id)
+ order = self.pool.get('pos.order').browse(cr, uid, active_id, context=context)
if not order.lines:
raise osv.except_osv(_('Error!'),_('No order lines defined for this sale '))
return True
@@ -99,15 +101,15 @@ class pos_make_payment(osv.osv_memory):
@return: New arch of view.
"""
-
-
result = super(pos_make_payment, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
+ if context is None:
+ context = {}
active_model = context.get('active_model')
active_id = context.get('active_id', False)
if not active_id or (active_model and active_model != 'pos.order'):
return result
- order = self.pool.get('pos.order').browse(cr, uid, active_id)
+ order = self.pool.get('pos.order').browse(cr, uid, active_id, context=context)
if order.amount_total == order.amount_paid:
result['arch'] = """
-
+
diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py
index 109f4509d81..8248359a928 100644
--- a/addons/survey/wizard/survey_answer.py
+++ b/addons/survey/wizard/survey_answer.py
@@ -49,7 +49,7 @@ class survey_question_wiz(osv.osv_memory):
@param context: A standard dictionary for contextual values
@return : Dictionary value for created view of particular survey pages.
"""
-
+
result = super(survey_question_wiz, self).fields_view_get(cr, uid, view_id, \
view_type, context, toolbar,submenu)
@@ -61,7 +61,8 @@ class survey_question_wiz(osv.osv_memory):
sur_response_obj = self.pool.get('survey.response')
que_col_head = self.pool.get('survey.question.column.heading')
user_obj = self.pool.get('res.users')
-
+ if context is None:
+ context = {}
if view_type in ['form']:
wiz_id = 0
if not context.has_key('sur_name_id'):
@@ -82,6 +83,8 @@ class survey_question_wiz(osv.osv_memory):
context.pop('active_id')
survey_id = context.get('survey_id', False)
+ if not survey_id:
+ return {}
sur_rec = survey_obj.browse(cr, uid, survey_id)
p_id = map(lambda x:x.id, sur_rec.page_ids)
total_pages = len(p_id)