From 3a87abb72e7ad88e1d5462072e889a3e6cb629d5 Mon Sep 17 00:00:00 2001
From: "MTR(OpenERP)" <>
Date: Wed, 18 Aug 2010 11:52:59 +0530
Subject: [PATCH] [IMP] Sale: Code Improved
bzr revid: mra@mra-laptop-20100818062259-8qi7bfpuk9wt7f4z
---
addons/sale/__init__.py | 3 +-
addons/sale/__openerp__.py | 3 +-
addons/sale/board_sale_demo.xml | 2 +-
addons/sale/board_sale_view.xml | 2 +-
addons/sale/company.py | 6 +--
addons/sale/company_view.xml | 2 -
addons/sale/product.py | 19 ++++----
addons/sale/sale.py | 7 +--
addons/sale/sale_demo.xml | 48 +++++++------------
addons/sale/sale_installer.py | 4 ++
addons/sale/stock.py | 3 ++
addons/sale/wizard/__init__.py | 3 +-
addons/sale/wizard/sale_line_invoice.py | 3 +-
addons/sale/wizard/sale_line_invoice.xml | 3 +-
addons/sale/wizard/sale_make_invoice.py | 10 ++--
addons/sale/wizard/sale_make_invoice.xml | 2 +-
.../sale/wizard/sale_make_invoice_advance.py | 10 ++--
.../sale/wizard/sale_make_invoice_advance.xml | 42 ++++++++--------
addons/sale_crm/board_sale_crm_view.xml | 2 +-
19 files changed, 83 insertions(+), 91 deletions(-)
diff --git a/addons/sale/__init__.py b/addons/sale/__init__.py
index 4d8541b4ab5..62fcf516a6b 100644
--- a/addons/sale/__init__.py
+++ b/addons/sale/__init__.py
@@ -31,5 +31,4 @@ import wizard
import report
import company
-# 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/sale/__openerp__.py b/addons/sale/__openerp__.py
index 322f767ca51..d432774c390 100644
--- a/addons/sale/__openerp__.py
+++ b/addons/sale/__openerp__.py
@@ -19,7 +19,6 @@
#
##############################################################################
-
{
'name': 'Sales Management',
'version': '1.0',
@@ -85,4 +84,4 @@
'active': False,
'certificate': '0058103601429',
}
-# 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/sale/board_sale_demo.xml b/addons/sale/board_sale_demo.xml
index 39f923a895b..c8918187258 100644
--- a/addons/sale/board_sale_demo.xml
+++ b/addons/sale/board_sale_demo.xml
@@ -3,4 +3,4 @@
-
+
\ No newline at end of file
diff --git a/addons/sale/board_sale_view.xml b/addons/sale/board_sale_view.xml
index fd3ed38587c..3e19e2fb4ee 100644
--- a/addons/sale/board_sale_view.xml
+++ b/addons/sale/board_sale_view.xml
@@ -37,4 +37,4 @@
-
+
\ No newline at end of file
diff --git a/addons/sale/company.py b/addons/sale/company.py
index 401a1a9c1d8..52d513f6dc9 100644
--- a/addons/sale/company.py
+++ b/addons/sale/company.py
@@ -29,9 +29,9 @@ class company(osv.osv):
"for security purpose"),
}
_defaults = {
- 'security_lead': lambda *a: 5.0,
+ 'security_lead': 5.0,
}
+
company()
-
-# 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/sale/company_view.xml b/addons/sale/company_view.xml
index ead9128d6f3..4088c38db08 100644
--- a/addons/sale/company_view.xml
+++ b/addons/sale/company_view.xml
@@ -1,7 +1,6 @@
-
res.company.mrp.config
res.company
@@ -13,6 +12,5 @@
-
diff --git a/addons/sale/product.py b/addons/sale/product.py
index ab28e693524..95d45c29575 100644
--- a/addons/sale/product.py
+++ b/addons/sale/product.py
@@ -20,22 +20,20 @@
##############################################################################
from osv import fields, osv
-from tools import config
-
-
class product_product(osv.osv):
- _name = 'product.product'
_inherit = 'product.product'
def _pricelist_calculate(self, cr, uid, ids, name, arg, context=None):
result = {}
- pricelist_obj=self.pool.get('product.pricelist')
- if name=='pricelist_purchase':
- pricelist_ids=pricelist_obj.search(cr,uid,[('type','=','purchase')])
+ pricelist_obj = self.pool.get('product.pricelist')
+ if context is None:
+ context = {}
+ if name == 'pricelist_purchase':
+ pricelist_ids = pricelist_obj.search(cr,uid,[('type','=','purchase')])
else:
- pricelist_ids=pricelist_obj.search(cr,uid,[('type','=','sale')])
- pricelist_browse=pricelist_obj.browse(cr,uid,pricelist_ids)
+ pricelist_ids = pricelist_obj.search(cr,uid,[('type','=','sale')])
+ pricelist_browse = pricelist_obj.browse(cr,uid,pricelist_ids)
for product in self.browse(cr, uid, ids, context):
result[product.id] = ""
for pricelist in pricelist_browse:
@@ -70,4 +68,5 @@ class product_product(osv.osv):
}
product_product()
-# 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/sale/sale.py b/addons/sale/sale.py
index 5a642c784f5..55548d9ae31 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -771,6 +771,7 @@ sale_order()
# - update it on change product and unit price
# - use it in report if there is a uos
class sale_order_line(osv.osv):
+
def _amount_line(self, cr, uid, ids, field_name, arg, context=None):
tax_obj = self.pool.get('account.tax')
cur_obj = self.pool.get('res.currency')
@@ -1170,9 +1171,9 @@ class sale_config_picking_policy(osv.osv_memory):
"in one or two operations by the worker.")
}
_defaults = {
- 'picking_policy': lambda *a: 'direct',
- 'order_policy': lambda *a: 'manual',
- 'step': lambda *a: 'one'
+ 'picking_policy': 'direct',
+ 'order_policy': 'manual',
+ 'step': 'one'
}
def execute(self, cr, uid, ids, context=None):
diff --git a/addons/sale/sale_demo.xml b/addons/sale/sale_demo.xml
index 59136f2b139..31ab58eb60b 100644
--- a/addons/sale/sale_demo.xml
+++ b/addons/sale/sale_demo.xml
@@ -2,9 +2,8 @@
-
+
+
@@ -12,10 +11,8 @@
-
-
+
+
@@ -26,10 +23,8 @@
-
-
+
+
New server config + material
@@ -70,10 +65,8 @@
make_to_stock
-
-
+
+
@@ -84,10 +77,8 @@
-
-
+
+
[PC2] Computer assembled on demand
@@ -107,9 +98,8 @@
make_to_order
-
+
+
@@ -141,9 +131,8 @@
-
+
+
@@ -175,9 +164,8 @@
-
+
+
@@ -202,9 +190,9 @@
-
+
Advance Product
@@ -216,4 +204,4 @@
-
+
\ No newline at end of file
diff --git a/addons/sale/sale_installer.py b/addons/sale/sale_installer.py
index d85273fa9a0..92758559439 100644
--- a/addons/sale/sale_installer.py
+++ b/addons/sale/sale_installer.py
@@ -18,6 +18,7 @@
# along with this program. If not, see .
#
##############################################################################
+
from osv import fields, osv
class sale_installer(osv.osv_memory):
@@ -41,4 +42,7 @@ class sale_installer(osv.osv_memory):
'sale_order_dates': fields.boolean('Sale Order Dates',
help="Add commitment, requested and effective dates on the sale order."),
}
+
sale_installer()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/sale/stock.py b/addons/sale/stock.py
index 6ff57e4d7d1..d8df1901024 100644
--- a/addons/sale/stock.py
+++ b/addons/sale/stock.py
@@ -29,6 +29,7 @@ class stock_move(osv.osv):
_defaults = {
'sale_line_id': False
}
+
stock_move()
class stock_picking(osv.osv):
@@ -115,6 +116,8 @@ class stock_picking(osv.osv):
invoice_obj = self.pool.get('account.invoice')
picking_obj = self.pool.get('stock.picking')
invoice_line_obj = self.pool.get('account.invoice.line')
+ if context is None:
+ context = {}
result = super(stock_picking, self).action_invoice_create(cursor, user,
ids, journal_id=journal_id, group=group, type=type,
diff --git a/addons/sale/wizard/__init__.py b/addons/sale/wizard/__init__.py
index ba6fd677a3c..6cf076164d8 100644
--- a/addons/sale/wizard/__init__.py
+++ b/addons/sale/wizard/__init__.py
@@ -23,5 +23,4 @@ import sale_make_invoice
import sale_line_invoice
import sale_make_invoice_advance
-
-# 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/sale/wizard/sale_line_invoice.py b/addons/sale/wizard/sale_line_invoice.py
index 195931ecb04..b7ea27a3049 100644
--- a/addons/sale/wizard/sale_line_invoice.py
+++ b/addons/sale/wizard/sale_line_invoice.py
@@ -110,7 +110,6 @@ class sale_order_line_make_invoice(osv.osv_memory):
(order_id,invoice_id) values (%s,%s)', (order.id, res))
return {}
-
sale_order_line_make_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/sale/wizard/sale_line_invoice.xml b/addons/sale/wizard/sale_line_invoice.xml
index eb9100c6777..63a26587d43 100644
--- a/addons/sale/wizard/sale_line_invoice.xml
+++ b/addons/sale/wizard/sale_line_invoice.xml
@@ -22,6 +22,5 @@
form
new
-
-
+
\ No newline at end of file
diff --git a/addons/sale/wizard/sale_make_invoice.py b/addons/sale/wizard/sale_make_invoice.py
index 850fc2e25d4..e1d26c7b987 100644
--- a/addons/sale/wizard/sale_make_invoice.py
+++ b/addons/sale/wizard/sale_make_invoice.py
@@ -29,15 +29,19 @@ class sale_make_invoice(osv.osv_memory):
'grouped': fields.boolean('Group the invoices', help='Check the box to group the invoices for the same customers'),
'invoice_date':fields.date('Invoice Date'),
}
- _default = {
- 'grouped' : lambda *a: False
+ _defaults = {
+ 'grouped': False
}
+
def view_init(self, cr, uid, fields_list, context=None):
+ if context is None:
+ context = {}
record_id = context and context.get('active_id', False)
order = self.pool.get('sale.order').browse(cr, uid, record_id)
if order.state == 'draft':
raise osv.except_osv(_('Warning !'),'You can not create invoice when sale order is not confirmed.')
return False
+
def make_invoices(self, cr, uid, ids, context={}):
order_obj = self.pool.get('sale.order')
newinv = []
@@ -68,5 +72,5 @@ class sale_make_invoice(osv.osv_memory):
}
sale_make_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/sale/wizard/sale_make_invoice.xml b/addons/sale/wizard/sale_make_invoice.xml
index 0bf0c37fdc2..2bef6b67513 100644
--- a/addons/sale/wizard/sale_make_invoice.xml
+++ b/addons/sale/wizard/sale_make_invoice.xml
@@ -28,4 +28,4 @@
-
+
\ No newline at end of file
diff --git a/addons/sale/wizard/sale_make_invoice_advance.py b/addons/sale/wizard/sale_make_invoice_advance.py
index ec944553cdc..0eac0308acc 100644
--- a/addons/sale/wizard/sale_make_invoice_advance.py
+++ b/addons/sale/wizard/sale_make_invoice_advance.py
@@ -19,7 +19,6 @@
##############################################################################
from osv import fields, osv
-from service import web_services
from tools.translate import _
import ir
@@ -31,9 +30,10 @@ class sale_advance_payment_inv(osv.osv_memory):
'amount': fields.float('Unit Price', size=(16, 2), required=True),
'qtty': fields.float('Quantity', size=(16, 2), required=True),
}
- _default = {
- 'qtty' : lambda *a: 1
+ _defaults = {
+ 'qtty': 1.0
}
+
def create_invoices(self, cr, uid, ids, context={}):
"""
To create invoices.
@@ -65,7 +65,7 @@ class sale_advance_payment_inv(osv.osv_memory):
that is defined as 'Automatic Invoice after delivery'."))
val = obj_lines.product_id_change(cr, uid, [], sale_adv_obj.product_id.id,
uom = False, partner_id = sale.partner_id.id, fposition_id = sale.fiscal_position.id)
- line_id =obj_lines.create(cr, uid, {
+ line_id = obj_lines.create(cr, uid, {
'name': val['value']['name'],
'account_id': val['value']['account_id'],
'price_unit': sale_adv_obj.amount,
@@ -181,4 +181,4 @@ class sale_open_invoice(osv.osv_memory):
sale_open_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/sale/wizard/sale_make_invoice_advance.xml b/addons/sale/wizard/sale_make_invoice_advance.xml
index be74ac94ac9..3257d1aafe8 100644
--- a/addons/sale/wizard/sale_make_invoice_advance.xml
+++ b/addons/sale/wizard/sale_make_invoice_advance.xml
@@ -6,17 +6,17 @@
sale.advance.payment.inv
form
-
+
@@ -34,15 +34,15 @@
sale.open.invoice
form
-
+
@@ -55,4 +55,4 @@
new
-
+
\ No newline at end of file
diff --git a/addons/sale_crm/board_sale_crm_view.xml b/addons/sale_crm/board_sale_crm_view.xml
index 610184b0e71..83fa1ea583a 100644
--- a/addons/sale_crm/board_sale_crm_view.xml
+++ b/addons/sale_crm/board_sale_crm_view.xml
@@ -102,4 +102,4 @@
-
+
\ No newline at end of file