diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 51a020b9b75..6c031955cc9 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -220,7 +220,8 @@ - + + diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 086db98b211..84dd2c90e7c 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -585,9 +585,9 @@ class account_move_line(osv.osv): company_list = [] for line in self.browse(cr, uid, ids, context=context): - if not line.company_id in company_list: + if company_list and not line.company_id.id in company_list: raise osv.except_osv(_('Warning !'), _('To reconcile the entries company should be the same for all entries')) - company_list.append(line.company_id) + company_list.append(line.company_id.id) for line in self.browse(cr, uid, ids, context): if line.reconcile_id: @@ -623,9 +623,9 @@ class account_move_line(osv.osv): company_list = [] for line in self.browse(cr, uid, ids, context=context): - if not line.company_id in company_list: + if company_list and not line.company_id.id in company_list: raise osv.except_osv(_('Warning !'), _('To reconcile the entries company should be the same for all entries')) - company_list.append(line.company_id) + company_list.append(line.company_id.id) for line in unrec_lines: if line.state <> 'valid': diff --git a/addons/product_margin/product_margin.py b/addons/product_margin/product_margin.py index 1bef9e54047..019e35b965c 100644 --- a/addons/product_margin/product_margin.py +++ b/addons/product_margin/product_margin.py @@ -26,9 +26,7 @@ import time class product_product(osv.osv): _inherit = "product.product" - - - def _product_margin(self, cr, uid, ids, field_names, arg, context): + def _product_margin(self, cr, uid, ids, field_names, arg, context=None): res = {} for val in self.browse(cr, uid, ids,context=context): res[val.id] = {} @@ -81,7 +79,7 @@ class product_product(osv.osv): res[val.id]['purchase_gap']=res[val.id]['normal_cost']-res[val.id]['total_cost'] if 'total_margin' in field_names: - res[val.id]['total_margin']=val.turnover-val.total_cost + res[val.id]['total_margin']=val.turnover-val.standard_price if 'expected_margin' in field_names: res[val.id]['expected_margin']=val.sale_expected-val.normal_cost if 'total_margin_rate' in field_names: @@ -106,7 +104,7 @@ class product_product(osv.osv): 'total_cost' : fields.function(_product_margin, method=True, type='float', string='Total Cost', multi='purchase',help="Sum of Multification of Invoice price and quantity of Supplier Invoices "), 'sale_expected' : fields.function(_product_margin, method=True, type='float', string='Expected Sale', multi='sale',help="Sum of Multification of Sale Catalog price and quantity of Customer Invoices"), 'normal_cost' : fields.function(_product_margin, method=True, type='float', string='Normal Cost', multi='purchase',help="Sum of Multification of Cost price and quantity of Supplier Invoices"), - 'total_margin' : fields.function(_product_margin, method=True, type='float', string='Total Margin', multi='total',help="Turnorder - Total Cost"), + 'total_margin' : fields.function(_product_margin, method=True, type='float', string='Total Margin', multi='total',help="Turnorder - Standard price"), 'expected_margin' : fields.function(_product_margin, method=True, type='float', string='Expected Margin', multi='total',help="Expected Sale - Normal Cost"), 'total_margin_rate' : fields.function(_product_margin, method=True, type='float', string='Total Margin (%)', multi='margin',help="Total margin * 100 / Turnover"), 'expected_margin_rate' : fields.function(_product_margin, method=True, type='float', string='Expected Margin (%)', multi='margin',help="Expected margin * 100 / Expected Sale"), diff --git a/addons/product_margin/product_margin_view.xml b/addons/product_margin/product_margin_view.xml index eaf64179015..145ea83858c 100644 --- a/addons/product_margin/product_margin_view.xml +++ b/addons/product_margin/product_margin_view.xml @@ -55,7 +55,6 @@ - @@ -85,5 +84,7 @@ + + diff --git a/addons/product_margin/wizard/product_margin.py b/addons/product_margin/wizard/product_margin.py index 1907c6695c2..a717e54dcdb 100644 --- a/addons/product_margin/wizard/product_margin.py +++ b/addons/product_margin/wizard/product_margin.py @@ -26,13 +26,24 @@ import netsvc import time from tools.translate import _ class product_margin(osv.osv_memory): - ''' - Product Margin - ''' + _name = 'product.margin' _description = 'Product Margin' - - def action_open_window(self, cr, uid, ids, context): + _columns = { + 'from_date': fields.date('From'), + 'to_date': fields.date('To'), + 'invoice_state':fields.selection([ + ('paid','Paid'), + ('open_paid','Open and Paid'), + ('draft_open_paid','Draft, Open and Paid'), + ],'Invoice State', select=True, required=True), + } + _defaults = { + 'from_date': lambda *a:time.strftime('%Y-01-01'), + 'to_date':lambda *a:time.strftime('%Y-12-31'), + 'invoice_state': lambda *a:"open_paid", + } + def action_open_window(self, cr, uid, ids, context=None): """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @@ -65,32 +76,4 @@ class product_margin(osv.osv_memory): 'search_view_id': id['res_id'] } - def action_cancel(self, cr, uid, ids, context=None): - """ - - - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param ids: the ID or list of IDs if we want more than one - - @return: - """ - return {'type':'ir.actions.act_window_close'} - - _columns = { - #TODO : import time required to get currect date - 'from_date': fields.date('From'), - #TODO : import time required to get currect date - 'to_date': fields.date('To'), - 'invoice_state':fields.selection([ - ('paid','Paid'), - ('open_paid','Open and Paid'), - ('draft_open_paid','Draft, Open and Paid'), - ],'Invoice State', select=True, required=True), - } - _defaults = { - 'from_date': lambda *a:time.strftime('%Y-01-01'), - 'to_date': lambda *a:time.strftime('%Y-01-01'), - 'invoice_state': lambda *a:"open_paid", - } product_margin() diff --git a/addons/product_margin/wizard/product_margin_view.xml b/addons/product_margin/wizard/product_margin_view.xml index 66869e120a5..404022e21fd 100644 --- a/addons/product_margin/wizard/product_margin_view.xml +++ b/addons/product_margin/wizard/product_margin_view.xml @@ -11,23 +11,22 @@ + -