|
30 | 30 | from openerp import tools
|
31 | 31 | from openerp.osv import fields, osv, expression
|
32 | 32 | from openerp.tools.translate import _
|
33 |
| -from openerp.tools.float_utils import float_round |
| 33 | +from openerp.tools.float_utils import float_round as round |
34 | 34 |
|
35 | 35 | import openerp.addons.decimal_precision as dp
|
36 | 36 |
|
@@ -729,8 +729,7 @@ class account_journal(osv.osv):
|
729 | 729 | 'currency': fields.many2one('res.currency', 'Currency', help='The currency used to enter statement'),
|
730 | 730 | 'entry_posted': fields.boolean('Autopost Created Moves', help='Check this box to automatically post entries of this journal. Note that legally, some entries may be automatically posted when the source document is validated (Invoices), whatever the status of this field.'),
|
731 | 731 | 'company_id': fields.many2one('res.company', 'Company', required=True, select=1, help="Company related to this journal"),
|
732 |
| - 'allow_date':fields.boolean('Check Date in Period', help= 'If set to True then do not accept the entry if the entry date is not into the period dates'), |
733 |
| - |
| 732 | + 'allow_date':fields.boolean('Check Date in Period', help= 'If checked, the entry won\'t be created if the entry date is not included into the selected period'), |
734 | 733 | 'profit_account_id' : fields.many2one('account.account', 'Profit Account'),
|
735 | 734 | 'loss_account_id' : fields.many2one('account.account', 'Loss Account'),
|
736 | 735 | 'internal_account_id' : fields.many2one('account.account', 'Internal Transfers Account', select=1),
|
@@ -841,16 +840,11 @@ def name_get(self, cr, user, ids, context=None):
|
841 | 840 | def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
|
842 | 841 | if not args:
|
843 | 842 | args = []
|
844 |
| - if context is None: |
845 |
| - context = {} |
846 |
| - ids = [] |
847 |
| - if context.get('journal_type', False): |
848 |
| - args += [('type','=',context.get('journal_type'))] |
849 |
| - if name: |
850 |
| - ids = self.search(cr, user, [('code', 'ilike', name)]+ args, limit=limit, context=context) |
851 |
| - if not ids: |
852 |
| - ids = self.search(cr, user, [('name', 'ilike', name)]+ args, limit=limit, context=context)#fix it ilike should be replace with operator |
853 |
| - |
| 843 | + if operator in expression.NEGATIVE_TERM_OPERATORS: |
| 844 | + domain = [('code', operator, name), ('name', operator, name)] |
| 845 | + else: |
| 846 | + domain = ['|', ('code', operator, name), ('name', operator, name)] |
| 847 | + ids = self.search(cr, user, expression.AND([domain, args]), limit=limit, context=context) |
854 | 848 | return self.name_get(cr, user, ids, context=context)
|
855 | 849 |
|
856 | 850 |
|
@@ -939,13 +933,11 @@ def finds(self, cr, uid, dt=None, exception=True, context=None):
|
939 | 933 | def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
|
940 | 934 | if args is None:
|
941 | 935 | args = []
|
942 |
| - if context is None: |
943 |
| - context = {} |
944 |
| - ids = [] |
945 |
| - if name: |
946 |
| - ids = self.search(cr, user, [('code', 'ilike', name)]+ args, limit=limit) |
947 |
| - if not ids: |
948 |
| - ids = self.search(cr, user, [('name', operator, name)]+ args, limit=limit) |
| 936 | + if operator in expression.NEGATIVE_TERM_OPERATORS: |
| 937 | + domain = [('code', operator, name), ('name', operator, name)] |
| 938 | + else: |
| 939 | + domain = ['|', ('code', operator, name), ('name', operator, name)] |
| 940 | + ids = self.search(cr, user, expression.AND([domain, args]), limit=limit, context=context) |
949 | 941 | return self.name_get(cr, user, ids, context=context)
|
950 | 942 |
|
951 | 943 |
|
@@ -1041,19 +1033,11 @@ def action_draft(self, cr, uid, ids, *args):
|
1041 | 1033 | def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
|
1042 | 1034 | if args is None:
|
1043 | 1035 | args = []
|
1044 |
| - if context is None: |
1045 |
| - context = {} |
1046 |
| - ids = [] |
1047 |
| - if name: |
1048 |
| - ids = self.search(cr, user, |
1049 |
| - [('code', 'ilike', name)] + args, |
1050 |
| - limit=limit, |
1051 |
| - context=context) |
1052 |
| - if not ids: |
1053 |
| - ids = self.search(cr, user, |
1054 |
| - [('name', operator, name)] + args, |
1055 |
| - limit=limit, |
1056 |
| - context=context) |
| 1036 | + if operator in expression.NEGATIVE_TERM_OPERATORS: |
| 1037 | + domain = [('code', operator, name), ('name', operator, name)] |
| 1038 | + else: |
| 1039 | + domain = ['|', ('code', operator, name), ('name', operator, name)] |
| 1040 | + ids = self.search(cr, user, expression.AND([domain, args]), limit=limit, context=context) |
1057 | 1041 | return self.name_get(cr, user, ids, context=context)
|
1058 | 1042 |
|
1059 | 1043 | def write(self, cr, uid, ids, vals, context=None):
|
@@ -1188,36 +1172,6 @@ def account_move_prepare(self, cr, uid, journal_id, date=False, ref='', company_
|
1188 | 1172 | 'company_id': company_id,
|
1189 | 1173 | }
|
1190 | 1174 |
|
1191 |
| - def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80): |
1192 |
| - """ |
1193 |
| - Returns a list of tupples containing id, name, as internally it is called {def name_get} |
1194 |
| - result format: {[(id, name), (id, name), ...]} |
1195 |
| -
|
1196 |
| - @param cr: A database cursor |
1197 |
| - @param user: ID of the user currently logged in |
1198 |
| - @param name: name to search |
1199 |
| - @param args: other arguments |
1200 |
| - @param operator: default operator is 'ilike', it can be changed |
1201 |
| - @param context: context arguments, like lang, time zone |
1202 |
| - @param limit: Returns first 'n' ids of complete result, default is 80. |
1203 |
| -
|
1204 |
| - @return: Returns a list of tuples containing id and name |
1205 |
| - """ |
1206 |
| - |
1207 |
| - if not args: |
1208 |
| - args = [] |
1209 |
| - ids = [] |
1210 |
| - if name: |
1211 |
| - ids += self.search(cr, user, [('name','ilike',name)]+args, limit=limit, context=context) |
1212 |
| - |
1213 |
| - if not ids and name and type(name) == int: |
1214 |
| - ids += self.search(cr, user, [('id','=',name)]+args, limit=limit, context=context) |
1215 |
| - |
1216 |
| - if not ids: |
1217 |
| - ids += self.search(cr, user, args, limit=limit, context=context) |
1218 |
| - |
1219 |
| - return self.name_get(cr, user, ids, context=context) |
1220 |
| - |
1221 | 1175 | def name_get(self, cursor, user, ids, context=None):
|
1222 | 1176 | if isinstance(ids, (int, long)):
|
1223 | 1177 | ids = [ids]
|
@@ -1843,10 +1797,12 @@ def _sum_period(self, cr, uid, ids, name, args, context):
|
1843 | 1797 | def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
|
1844 | 1798 | if not args:
|
1845 | 1799 | args = []
|
1846 |
| - if context is None: |
1847 |
| - context = {} |
1848 |
| - ids = self.search(cr, user, ['|',('name',operator,name),('code',operator,name)] + args, limit=limit, context=context) |
1849 |
| - return self.name_get(cr, user, ids, context) |
| 1800 | + if operator in expression.NEGATIVE_TERM_OPERATORS: |
| 1801 | + domain = [('code', operator, name), ('name', operator, name)] |
| 1802 | + else: |
| 1803 | + domain = ['|', ('code', operator, name), ('name', operator, name)] |
| 1804 | + ids = self.search(cr, user, expression.AND([domain, args]), limit=limit, context=context) |
| 1805 | + return self.name_get(cr, user, ids, context=context) |
1850 | 1806 |
|
1851 | 1807 | def name_get(self, cr, uid, ids, context=None):
|
1852 | 1808 | if isinstance(ids, (int, long)):
|
@@ -1938,15 +1894,15 @@ def copy_data(self, cr, uid, id, default=None, context=None):
|
1938 | 1894 | #
|
1939 | 1895 | 'base_code_id': fields.many2one('account.tax.code', 'Account Base Code', help="Use this code for the tax declaration."),
|
1940 | 1896 | 'tax_code_id': fields.many2one('account.tax.code', 'Account Tax Code', help="Use this code for the tax declaration."),
|
1941 |
| - 'base_sign': fields.float('Base Code Sign', help="Usually 1 or -1."), |
1942 |
| - 'tax_sign': fields.float('Tax Code Sign', help="Usually 1 or -1."), |
| 1897 | + 'base_sign': fields.float('Base Code Sign', help="Usually 1 or -1.", digits_compute=get_precision_tax()), |
| 1898 | + 'tax_sign': fields.float('Tax Code Sign', help="Usually 1 or -1.", digits_compute=get_precision_tax()), |
1943 | 1899 |
|
1944 | 1900 | # Same fields for refund invoices
|
1945 | 1901 |
|
1946 | 1902 | 'ref_base_code_id': fields.many2one('account.tax.code', 'Refund Base Code', help="Use this code for the tax declaration."),
|
1947 | 1903 | 'ref_tax_code_id': fields.many2one('account.tax.code', 'Refund Tax Code', help="Use this code for the tax declaration."),
|
1948 |
| - 'ref_base_sign': fields.float('Refund Base Code Sign', help="Usually 1 or -1."), |
1949 |
| - 'ref_tax_sign': fields.float('Refund Tax Code Sign', help="Usually 1 or -1."), |
| 1904 | + 'ref_base_sign': fields.float('Refund Base Code Sign', help="Usually 1 or -1.", digits_compute=get_precision_tax()), |
| 1905 | + 'ref_tax_sign': fields.float('Refund Tax Code Sign', help="Usually 1 or -1.", digits_compute=get_precision_tax()), |
1950 | 1906 | 'include_base_amount': fields.boolean('Included in base amount', help="Indicates if the amount of tax must be included in the base amount for the computation of the next taxes"),
|
1951 | 1907 | 'company_id': fields.many2one('res.company', 'Company', required=True),
|
1952 | 1908 | 'description': fields.char('Tax Code'),
|
@@ -1975,15 +1931,11 @@ def name_search(self, cr, user, name, args=None, operator='ilike', context=None,
|
1975 | 1931 | """
|
1976 | 1932 | if not args:
|
1977 | 1933 | args = []
|
1978 |
| - if context is None: |
1979 |
| - context = {} |
1980 |
| - ids = [] |
1981 |
| - if name: |
1982 |
| - ids = self.search(cr, user, [('description', '=', name)] + args, limit=limit, context=context) |
1983 |
| - if not ids: |
1984 |
| - ids = self.search(cr, user, [('name', operator, name)] + args, limit=limit, context=context) |
| 1934 | + if operator in expression.NEGATIVE_TERM_OPERATORS: |
| 1935 | + domain = [('description', operator, name), ('name', operator, name)] |
1985 | 1936 | else:
|
1986 |
| - ids = self.search(cr, user, args, limit=limit, context=context or {}) |
| 1937 | + domain = ['|', ('description', operator, name), ('name', operator, name)] |
| 1938 | + ids = self.search(cr, user, expression.AND([domain, args]), limit=limit, context=context) |
1987 | 1939 | return self.name_get(cr, user, ids, context=context)
|
1988 | 1940 |
|
1989 | 1941 | def write(self, cr, uid, ids, vals, context=None):
|
@@ -2144,7 +2096,7 @@ def compute_all(self, cr, uid, taxes, price_unit, quantity, product=None, partne
|
2144 | 2096 | tax_compute_precision = precision
|
2145 | 2097 | if taxes and taxes[0].company_id.tax_calculation_rounding_method == 'round_globally':
|
2146 | 2098 | tax_compute_precision += 5
|
2147 |
| - totalin = totalex = float_round(price_unit * quantity, precision) |
| 2099 | + totalin = totalex = round(price_unit * quantity, precision) |
2148 | 2100 | tin = []
|
2149 | 2101 | tex = []
|
2150 | 2102 | for tax in taxes:
|
|
0 commit comments