diff --git a/addons/sale_analytic_plans/sale_analytic_plans.py b/addons/sale_analytic_plans/sale_analytic_plans.py
index 31f1cc9c327..0d10817e19a 100644
--- a/addons/sale_analytic_plans/sale_analytic_plans.py
+++ b/addons/sale_analytic_plans/sale_analytic_plans.py
@@ -23,7 +23,6 @@ import time
from osv import fields, osv
class sale_order_line(osv.osv):
- _name = 'sale.order.line'
_inherit = 'sale.order.line'
_columns = {
'analytics_id':fields.many2one('account.analytic.plan.instance','Analytic Distribution'),
diff --git a/addons/sale_analytic_plans/sale_analytic_plans_view.xml b/addons/sale_analytic_plans/sale_analytic_plans_view.xml
index 5769cd18f2f..932b54898e9 100644
--- a/addons/sale_analytic_plans/sale_analytic_plans_view.xml
+++ b/addons/sale_analytic_plans/sale_analytic_plans_view.xml
@@ -1,6 +1,6 @@
-
+
sale.order.form.inherit
@@ -36,5 +36,5 @@
-
+
diff --git a/addons/sale_crm/sale_crm_view.xml b/addons/sale_crm/sale_crm_view.xml
index 5cf4cf552f0..4ded6620847 100644
--- a/addons/sale_crm/sale_crm_view.xml
+++ b/addons/sale_crm/sale_crm_view.xml
@@ -1,47 +1,48 @@
-
+
-
- CRM - Opportunities - Quote Inherit
- crm.lead
- form
-
-
-
-
-
-
-
+
+ CRM - Opportunities - Quote Inherit
+ crm.lead
+ form
+
+
+
+
+
+
+
-
- sale.order.inherit
- sale.order
- form
-
-
-
-
-
-
-
-
-
- sale.order.list.select
- sale.order
- search
-
-
-
-
-
-
-
-
-
-
+
+ sale.order.inherit
+ sale.order
+ form
+
+
+
+
+
+
+
+
+
+ sale.order.list.select
+ sale.order
+ search
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/sale_journal/report/sale_journal_report.py b/addons/sale_journal/report/sale_journal_report.py
index 0607f3be607..2e793d91933 100644
--- a/addons/sale_journal/report/sale_journal_report.py
+++ b/addons/sale_journal/report/sale_journal_report.py
@@ -41,7 +41,7 @@ class sale_journal_report(osv.osv):
('done', 'Done'),
('cancel', 'Cancel')
], 'Order State', readonly=True),
- 'journal_id':fields.many2one('sale_journal.sale.journal', 'Journal', readonly=True),
+ 'journal_id': fields.many2one('sale_journal.sale.journal', 'Journal', readonly=True),
'quantity': fields.float('Quantities', readonly=True),
'price_total': fields.float('Total Price', readonly=True),
'price_average': fields.float('Average Price', readonly=True),
@@ -86,7 +86,7 @@ class sale_journal_picking_report(osv.osv):
_auto = False
_columns = {
'name': fields.char('Year', size=64, required=False, readonly=True),
- 'month':fields.selection([('01', 'January'), ('02', 'February'), ('03', 'March'), ('04', 'April'), ('05', 'May'), ('06', 'June'),
+ 'month': fields.selection([('01', 'January'), ('02', 'February'), ('03', 'March'), ('04', 'April'), ('05', 'May'), ('06', 'June'),
('07', 'July'), ('08', 'August'), ('09', 'September'), ('10', 'October'), ('11', 'November'), ('12', 'December')], 'Month', readonly=True),
'invoice_state':fields.selection([
@@ -103,7 +103,7 @@ class sale_journal_picking_report(osv.osv):
('cancel', 'cancel'),
], 'State', readonly=True),
'invoice_type_id': fields.many2one('sale_journal.invoice.type', 'Invoicing method', readonly=True),
- 'journal_id':fields.many2one('sale_journal.picking.journal', 'Journal', readonly=True),
+ 'journal_id': fields.many2one('sale_journal.picking.journal', 'Journal', readonly=True),
'quantity': fields.float('Quantities', readonly=True),
'price_total': fields.float('Total Price', readonly=True),
'price_average': fields.float('Average Price', readonly=True),
diff --git a/addons/sale_journal/sale_journal.py b/addons/sale_journal/sale_journal.py
index 4f275505e95..02fc8b71a7a 100644
--- a/addons/sale_journal/sale_journal.py
+++ b/addons/sale_journal/sale_journal.py
@@ -148,8 +148,8 @@ class picking_journal(osv.osv):
'note': fields.text('Note'),
}
_defaults = {
- 'date': lambda *a: time.strftime('%Y-%m-%d'),
- 'date_created': lambda *a: time.strftime('%Y-%m-%d'),
+ 'date': time.strftime('%Y-%m-%d'),
+ 'date_created': time.strftime('%Y-%m-%d'),
'user_id': lambda self,cr,uid,context: uid,
'state': lambda self,cr,uid,context: 'draft',
}
@@ -161,12 +161,15 @@ class picking_journal(osv.osv):
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'stock.picking', pickid, 'button_cancel', cr)
return True
+
def button_open(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, {'state':'open'})
return True
+
def button_draft(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, {'state':'draft'})
return True
+
def button_close(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, {'state':'done', 'date_validation':time.strftime('%Y-%m-%d')})
return True
@@ -197,13 +200,13 @@ class res_partner(osv.osv):
_columns = {
'property_invoice_type': fields.property(
'sale_journal.invoice.type',
- type='many2one',
- relation='sale_journal.invoice.type',
- string="Invoicing Method",
- method=True,
- view_load=True,
- group_name="Accounting Properties",
- help="The type of journal used for sales and picking."),
+ type = 'many2one',
+ relation = 'sale_journal.invoice.type',
+ string = "Invoicing Method",
+ method = True,
+ view_load = True,
+ group_name = "Accounting Properties",
+ help = "The type of journal used for sales and picking."),
}
res_partner()
diff --git a/addons/sale_journal/sale_journal_view.xml b/addons/sale_journal/sale_journal_view.xml
index 052d7e09777..73377a173fe 100644
--- a/addons/sale_journal/sale_journal_view.xml
+++ b/addons/sale_journal/sale_journal_view.xml
@@ -148,10 +148,12 @@
sale.order
-
-
-
-
+
+
+
+
+
+
@@ -403,10 +405,10 @@
tree
-
-
-
-
+
+
+
+
diff --git a/addons/sale_margin/__init__.py b/addons/sale_margin/__init__.py
index ff24fd198d9..02e1dad1bac 100644
--- a/addons/sale_margin/__init__.py
+++ b/addons/sale_margin/__init__.py
@@ -18,7 +18,6 @@
#
##############################################################################
-import invoice_margin
import report
import sale_margin
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/sale_margin/__openerp__.py b/addons/sale_margin/__openerp__.py
index 4b4c2f62b5c..0a0d523a7ae 100644
--- a/addons/sale_margin/__openerp__.py
+++ b/addons/sale_margin/__openerp__.py
@@ -21,8 +21,12 @@
{
"name":"Margins in Sale Orders",
"version":"1.0",
- "author":"Tiny",
"category" : "Generic Modules/Sales & Purchases",
+ "description": """
+ This module adds the 'Margin' on sales order,
+ which gives the profitability by calculating the difference between the Unit Price and Cost Price
+ """,
+ "author":"Tiny",
"depends":["sale"],
"demo_xml":[],
"update_xml":["security/ir.model.access.csv","sale_margin_view.xml","report/report_margin_view.xml"],
diff --git a/addons/sale_margin/invoice_margin.py b/addons/sale_margin/invoice_margin.py
deleted file mode 100644
index aad746ce903..00000000000
--- a/addons/sale_margin/invoice_margin.py
+++ /dev/null
@@ -1,44 +0,0 @@
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# 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 .
-#
-##############################################################################
-
-from osv import fields,osv
-import pooler
-from tools import config
-
-class account_invoice_line(osv.osv):
- _name = "account.invoice.line"
- _inherit = "account.invoice.line"
- _columns = {
- 'cost_price': fields.float('Cost Price', digits=(16, 2)),
- }
- def write(self, cr, uid, ids, vals, context={}):
- if vals.get('product_id', False):
- res = self.pool.get('product.product').read(cr, uid, [vals['product_id']], ['standard_price'])
- vals['cost_price'] = res[0]['standard_price']
- return super(account_invoice_line, self).write(cr, uid, ids, vals, context)
-
- def create(self, cr, uid, vals, context={}):
- if vals.get('product_id',False):
- res = self.pool.get('product.product').read(cr, uid, [vals['product_id']], ['standard_price'])
- vals['cost_price'] = res[0]['standard_price']
- return super(account_invoice_line, self).create(cr, uid, vals, context)
-account_invoice_line()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/sale_margin/sale_margin.py b/addons/sale_margin/sale_margin.py
index 7d2c644de6b..daa8011246e 100644
--- a/addons/sale_margin/sale_margin.py
+++ b/addons/sale_margin/sale_margin.py
@@ -23,7 +23,6 @@ import pooler
from tools import config
class sale_order_line(osv.osv):
- _name = "sale.order.line"
_inherit = "sale.order.line"
def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
@@ -67,7 +66,7 @@ class sale_order(osv.osv):
return result
_columns = {
- 'margin': fields.function(_product_margin, method=True, string='Margin', store=True),
+ 'margin': fields.function(_product_margin, method=True, string='Margin', store=True, help="It gives profitability by calculating the difference between the Unit Price and Cost Price"),
}
sale_order()
@@ -76,7 +75,7 @@ class stock_picking(osv.osv):
_inherit = 'stock.picking'
_columns = {
- 'invoice_ids': fields.many2many('account.invoice', 'picking_invoice_rel', 'picking_id', 'invoice_id', 'Invoices', domain=[('type','=','in_invoice')]),
+ 'invoice_ids': fields.many2many('account.invoice', 'picking_invoice_rel', 'picking_id', 'invoice_id', 'Invoices', domain=[('type','=','out_invoice')]),
}
def create_invoice(self, cr, uid, ids, *args):
@@ -91,4 +90,23 @@ class stock_picking(osv.osv):
return True
stock_picking()
+
+class account_invoice_line(osv.osv):
+ _inherit = "account.invoice.line"
+ _columns = {
+ 'cost_price': fields.float('Cost Price', digits=(16, 2)),
+ }
+ def write(self, cr, uid, ids, vals, context={}):
+ if vals.get('product_id', False):
+ res = self.pool.get('product.product').read(cr, uid, [vals['product_id']], ['standard_price'])
+ vals['cost_price'] = res[0]['standard_price']
+ return super(account_invoice_line, self).write(cr, uid, ids, vals, context)
+
+ def create(self, cr, uid, vals, context={}):
+ if vals.get('product_id',False):
+ res = self.pool.get('product.product').read(cr, uid, [vals['product_id']], ['standard_price'])
+ vals['cost_price'] = res[0]['standard_price']
+ return super(account_invoice_line, self).create(cr, uid, vals, context)
+
+account_invoice_line()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/sale_margin/sale_margin_view.xml b/addons/sale_margin/sale_margin_view.xml
index 0b470ec824c..e8f3e12a720 100644
--- a/addons/sale_margin/sale_margin_view.xml
+++ b/addons/sale_margin/sale_margin_view.xml
@@ -67,15 +67,15 @@
picking.margin.view.form
form
stock.picking
-
+
-
+
-
-
+
+
diff --git a/addons/sale_mrp/sale_mrp.py b/addons/sale_mrp/sale_mrp.py
index b5e91bc76ac..e8cb0c61f91 100644
--- a/addons/sale_mrp/sale_mrp.py
+++ b/addons/sale_mrp/sale_mrp.py
@@ -25,29 +25,31 @@ from osv import osv, fields
class mrp_production(osv.osv):
_inherit = 'mrp.production'
- def _ref_calc(self, cr, uid, ids, field_names=None, arg=False, context={}):
+ def _ref_calc(self, cr, uid, ids, field_names=None, arg=False, context=None):
""" Finds reference of sale order for production order.
@param field_names: Names of fields.
@param arg: User defined arguments
@return: Dictionary of values.
"""
+ res = {}
+ if context is None:
+ context = {}
if not field_names:
field_names = []
- res = {}
for id in ids:
res[id] = {}.fromkeys(field_names, False)
for f in field_names:
field_name = False
if f == 'sale_name':
field_name = 'name'
- if f=='sale_ref':
+ if f == 'sale_ref':
field_name = 'client_order_ref'
for key, value in self._get_sale_ref(cr, uid, ids, field_name).items():
res[key][f] = value
return res
def _get_sale_ref(self, cr, uid, ids, field_name=False):
- move_obj=self.pool.get('stock.move')
+ move_obj = self.pool.get('stock.move')
def get_parent_move(move_id):
move = move_obj.browse(cr, uid, move_id)
@@ -55,8 +57,8 @@ class mrp_production(osv.osv):
return get_parent_move(move.move_dest_id.id)
return move_id
+ res = {}
productions = self.read(cr, uid, ids, ['id','move_prod_id'])
- res={}
for production in productions:
res[production['id']] = False
if production.get('move_prod_id',False):
@@ -65,7 +67,7 @@ class mrp_production(osv.osv):
move = move_obj.browse(cr,uid,parent_move_line)
if field_name == 'name':
res[production['id']] = move.sale_line_id and move.sale_line_id.order_id.name or False
- if field_name=='client_order_ref':
+ if field_name == 'client_order_ref':
res[production['id']] = move.sale_line_id and move.sale_line_id.order_id.client_order_ref or False
return res