1253
by Mustufa Rangwala
inherit res.partner object |
1 |
##############################################################################
|
2 |
#
|
|
3 |
# Copyright (c) 2007 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
|
4 |
#
|
|
5 |
# WARNING: This program as such is intended to be used by professional
|
|
6 |
# programmers who take the whole responsability of assessing all potential
|
|
7 |
# consequences resulting from its eventual inadequacies and bugs
|
|
8 |
# End users who are looking for a ready-to-use solution with commercial
|
|
9 |
# garantees and support are strongly adviced to contract a Free Software
|
|
10 |
# Service Company
|
|
11 |
#
|
|
12 |
# This program is Free Software; you can redistribute it and/or
|
|
13 |
# modify it under the terms of the GNU General Public License
|
|
14 |
# as published by the Free Software Foundation; either version 2
|
|
15 |
# of the License, or (at your option) any later version.
|
|
16 |
#
|
|
17 |
# This program is distributed in the hope that it will be useful,
|
|
1426
by Jay vora
Added an object of ata_carnet |
18 |
# but WITHOUT ANY WARRANTY; without even the impli(ed warranty of
|
1253
by Mustufa Rangwala
inherit res.partner object |
19 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
# GNU General Public License for more details.
|
|
21 |
#
|
|
22 |
# You should have received a copy of the GNU General Public License
|
|
23 |
# along with this program; if not, write to the Free Software
|
|
24 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
25 |
#
|
|
26 |
##############################################################################
|
|
27 |
||
1254
by Mustufa Rangwala
add cci_missions_certificate_type,cci_missions.site objects |
28 |
from osv import fields, osv |
1268
by Mustufa Rangwala
added some default values, |
29 |
import time |
1442
by Mustufa Rangwala
validity date as a default (creation_date+1 yr - day), |
30 |
from datetime import date,timedelta |
31 |
import datetime |
|
1588
by Jay vora
Added 'Historize' action related code to communication stuff for cci_missions_embassy_folder object,overwrote create method of crm_case_log,added workflow actions to history tab. |
32 |
import pooler |
1589
by Mustufa Rangwala
*add functionality (modify workflow function): |
33 |
import netsvc |
1434
by Jay vora
Modified functions for insurer_id and member_state in ata_carnet object |
34 |
|
35 |
STATE = [ |
|
1440
by qdp
*spaces replaced by tabulations |
36 |
('none', 'Non Member'), |
37 |
('canceled', 'Canceled Member'), |
|
38 |
('old', 'Old Member'), |
|
39 |
('waiting', 'Waiting Member'), |
|
40 |
('invoiced', 'Invoiced Member'), |
|
41 |
('associated', 'Associated Member'), |
|
42 |
('free', 'Free Member'), |
|
43 |
('paid', 'Paid Member'), |
|
1434
by Jay vora
Modified functions for insurer_id and member_state in ata_carnet object |
44 |
]
|
45 |
||
1253
by Mustufa Rangwala
inherit res.partner object |
46 |
class res_partner(osv.osv): |
1440
by qdp
*spaces replaced by tabulations |
47 |
_inherit = 'res.partner' |
48 |
_description = 'res.partner' |
|
1648
by Mustufa Rangwala
* add onchange on partner_id for ata object |
49 |
|
1440
by qdp
*spaces replaced by tabulations |
50 |
_columns = { |
51 |
'asker_name': fields.char('Asker Name',size=50), |
|
52 |
'asker_address': fields.char('Asker Address',size=50), |
|
53 |
'asker_zip_id': fields.many2one('res.partner.zip','Asker Zip Code'), |
|
54 |
'sender_name': fields.char('Sender Name',size=50), |
|
1649
by Mustufa Rangwala
*on partner : |
55 |
'insurer_id' : fields.char('Insurer ID',size=50), |
1440
by qdp
*spaces replaced by tabulations |
56 |
}
|
1254
by Mustufa Rangwala
add cci_missions_certificate_type,cci_missions.site objects |
57 |
|
1253
by Mustufa Rangwala
inherit res.partner object |
58 |
res_partner() |
59 |
||
1254
by Mustufa Rangwala
add cci_missions_certificate_type,cci_missions.site objects |
60 |
class cci_missions_site(osv.osv): |
1440
by qdp
*spaces replaced by tabulations |
61 |
_name = 'cci_missions.site' |
62 |
_description = 'cci_missions.site' |
|
63 |
||
64 |
_columns = { |
|
65 |
'name' : fields.char('Name of the Site',size=50,required=True), |
|
66 |
'official_name_1' : fields.char('Official Name of the Site',size=50,required=True), |
|
67 |
'official_name_2' : fields.char('Official Name of the Site',size=50), |
|
68 |
'official_name_3' : fields.char('Official Name of the Site',size=50), |
|
69 |
'official_name_4' : fields.char('Official Name of the Site',size=50), |
|
1557
by qdp
cci_mission.py: |
70 |
'embassy_sequence_id' : fields.many2one('ir.sequence','Sequence for Embassy Folder'), |
1440
by qdp
*spaces replaced by tabulations |
71 |
}
|
1254
by Mustufa Rangwala
add cci_missions_certificate_type,cci_missions.site objects |
72 |
|
73 |
cci_missions_site() |
|
74 |
||
1260
by Mustufa Rangwala
add objects(cci_missions_embassy_folder ,cci_missions_embassy_folder_line |
75 |
class cci_missions_embassy_folder(osv.osv): |
1440
by qdp
*spaces replaced by tabulations |
76 |
_name = 'cci_missions.embassy_folder' |
77 |
_description = 'cci_missions.embassy_folder' |
|
78 |
_inherits = {'crm.case': 'crm_case_id'} |
|
79 |
||
1570
by qdp
*removed copy of the note to diplay on the invoice when creating an embassy folder from a certificate or legalization |
80 |
def _cci_mission_send(self, cr, uid, ids, *args): |
81 |
self.write(cr, uid, ids, {'state':'pending',}) |
|
1588
by Jay vora
Added 'Historize' action related code to communication stuff for cci_missions_embassy_folder object,overwrote create method of crm_case_log,added workflow actions to history tab. |
82 |
cases = self.browse(cr, uid, ids) |
2037
by Jay vora
Added the functionality of Grouping invoices.Modified existing wizard files. |
83 |
self._history(cr, uid, cases, 'Send', history=True,) |
1570
by qdp
*removed copy of the note to diplay on the invoice when creating an embassy folder from a certificate or legalization |
84 |
return True |
85 |
||
86 |
def _cci_mission_got_back(self,cr,uid,ids,*args): |
|
87 |
self.write(cr, uid, ids, {'state':'open',}) |
|
1588
by Jay vora
Added 'Historize' action related code to communication stuff for cci_missions_embassy_folder object,overwrote create method of crm_case_log,added workflow actions to history tab. |
88 |
cases = self.browse(cr, uid, ids) |
2037
by Jay vora
Added the functionality of Grouping invoices.Modified existing wizard files. |
89 |
self._history(cr, uid, cases, 'Got Back', history=True) |
2746
by qdp
*moved the fields for AWEX stuff from cci_translation on embassy_folder_line (+modified the views) |
90 |
for id in self.browse(cr, uid, ids): |
91 |
data = {} |
|
92 |
obj_folder_line = self.pool.get('cci_missions.embassy_folder_line') |
|
93 |
temp = obj_folder_line.search(cr, uid, [('folder_id','=',id.id),('type','=','Translation')]) |
|
94 |
if temp: |
|
95 |
translation_line = obj_folder_line.browse(cr, uid, [temp[0]])[0] |
|
96 |
if translation_line.awex_eligible and id.partner_id.awex_eligible == 'yes': |
|
97 |
#look for an existing credit line in the current time
|
|
98 |
credit_line = self.pool.get('credit.line').search(cr, uid, [('from_date','<=',time.strftime('%Y-%m-%d')), ('to_date', '>=', time.strftime('%Y-%m-%d'))]) |
|
99 |
if credit_line: |
|
100 |
#if there is one available: get available amount from it
|
|
101 |
amount = self.pool.get('credit.line').browse(cr, uid,[credit_line[0]])[0].get_available_amount(cr, uid, credit_line[0], translation_line.customer_amount, id.partner_id.id) |
|
102 |
if amount > 0: |
|
103 |
data['awex_amount'] = amount |
|
104 |
data['credit_line_id'] = credit_line[0] |
|
105 |
else: |
|
106 |
data['awex_eligible'] = False |
|
107 |
obj_folder_line.write(cr, uid, [translation_line.id], data) |
|
1570
by qdp
*removed copy of the note to diplay on the invoice when creating an embassy folder from a certificate or legalization |
108 |
return True |
109 |
||
110 |
def _cci_mission_done_folder(self,cr,uid,ids,*args): |
|
1571
by qdp
*corrected creation of embassy folder from a certificate or legalization |
111 |
self.write(cr, uid, ids, {'state':'done','invoice_date': time.strftime('%Y-%m-%d %H:%M:%S')}) |
1588
by Jay vora
Added 'Historize' action related code to communication stuff for cci_missions_embassy_folder object,overwrote create method of crm_case_log,added workflow actions to history tab. |
112 |
cases = self.browse(cr, uid, ids) |
2037
by Jay vora
Added the functionality of Grouping invoices.Modified existing wizard files. |
113 |
self._history(cr, uid, cases, 'Invoiced', history=True) |
1588
by Jay vora
Added 'Historize' action related code to communication stuff for cci_missions_embassy_folder object,overwrote create method of crm_case_log,added workflow actions to history tab. |
114 |
return True |
115 |
||
2037
by Jay vora
Added the functionality of Grouping invoices.Modified existing wizard files. |
116 |
def _history(self, cr, uid,ids,keyword, history=False, email=False, context={}): |
1588
by Jay vora
Added 'Historize' action related code to communication stuff for cci_missions_embassy_folder object,overwrote create method of crm_case_log,added workflow actions to history tab. |
117 |
for case in ids: |
118 |
data = { |
|
119 |
'name': keyword, |
|
120 |
'som': case.som.id, |
|
121 |
'canal_id': case.canal_id.id, |
|
122 |
'user_id': uid, |
|
123 |
'case_id': case.crm_case_id.id |
|
124 |
}
|
|
125 |
obj = self.pool.get('crm.case.log') |
|
126 |
obj.create(cr, uid, data, context) |
|
1567
by Mustufa Rangwala
state field override on embasy folder object (work flow) |
127 |
return True |
128 |
||
1557
by qdp
cci_mission.py: |
129 |
def create(self, cr, uid, vals, *args, **kwargs): |
130 |
# Overwrite the name field to set next sequence according to the sequence in for the embassy folder related in the site_id
|
|
131 |
if vals['site_id']: |
|
132 |
data = self.pool.get('cci_missions.site').browse(cr, uid,vals['site_id']) |
|
133 |
seq = self.pool.get('ir.sequence').get(cr, uid,data.embassy_sequence_id.code) |
|
134 |
if seq: |
|
135 |
vals.update({'name': seq}) |
|
1609
by qdp
*overall improvement |
136 |
temp = super(osv.osv,self).create(cr, uid, vals, *args, **kwargs) |
2037
by Jay vora
Added the functionality of Grouping invoices.Modified existing wizard files. |
137 |
self._history(cr, uid,self.browse(cr, uid, [temp]), 'Created', history=True) |
1625
by Jay vora
Modified invoicing functionality for member_price by calling price_get function of membership. |
138 |
return temp |
1609
by qdp
*overall improvement |
139 |
|
1557
by qdp
cci_mission.py: |
140 |
|
141 |
||
1541
by Mustufa Rangwala
- add invoice_id on embassy object |
142 |
def onchange_partner_id(self, cr, uid, ids, part): |
143 |
if not part: |
|
144 |
return {'value':{'partner_address_id': False}} |
|
2072
by Mustufa Rangwala
* modify onchange for partner:ata_carnets, certificates, legalizations, embassy_folders |
145 |
part_obj = self.pool.get('res.partner') |
146 |
data_partner = part_obj.browse(cr,uid,part) |
|
147 |
if data_partner.alert_legalisations: |
|
2076
by Mustufa Rangwala
* modify onchange partner |
148 |
raise osv.except_osv('Error!',data_partner.alert_explanation or 'Partner is not valid') |
2072
by Mustufa Rangwala
* modify onchange for partner:ata_carnets, certificates, legalizations, embassy_folders |
149 |
addr = part_obj.address_get(cr, uid, [part], ['contact']) |
1541
by Mustufa Rangwala
- add invoice_id on embassy object |
150 |
data = {'partner_address_id':addr['contact']} |
151 |
return {'value':data} |
|
152 |
||
1440
by qdp
*spaces replaced by tabulations |
153 |
def check_folder_line(self, cr, uid, ids): |
2746
by qdp
*moved the fields for AWEX stuff from cci_translation on embassy_folder_line (+modified the views) |
154 |
#CONSTRAINT: For each embassy Folder, it can only be one embassy_folder_line of each type.
|
1440
by qdp
*spaces replaced by tabulations |
155 |
data_folder = self.browse(cr,uid,ids) |
156 |
list = [] |
|
157 |
for folder in data_folder: |
|
158 |
for line in folder.embassy_folder_line_ids: |
|
159 |
if line.type and line.type in list: |
|
160 |
return False |
|
161 |
list.append(line.type) |
|
162 |
return True |
|
163 |
||
164 |
_columns = { |
|
165 |
'crm_case_id' : fields.many2one('crm.case','Case'), |
|
1543
by qdp
* user_id on crm.case.log is now uid by default |
166 |
'member_price' : fields.boolean('Member Price Allowed'), |
1440
by qdp
*spaces replaced by tabulations |
167 |
'customer_reference' : fields.char('Folders Reference for the Customer',size=30), |
168 |
'destination_id' : fields.many2one('res.country','Destination Country'), |
|
169 |
'link_ids': fields.one2many('cci_missions.dossier','embassy_folder_id','Linked Documents'), |
|
170 |
'internal_note': fields.text('Internal Note'), |
|
171 |
'invoice_note':fields.text('Note to Display on the Invoice',help='to display as the last embassy_folder_line of this embassy_folder.'), |
|
172 |
'embassy_folder_line_ids' : fields.one2many('cci_missions.embassy_folder_line','folder_id','Details'), |
|
1557
by qdp
cci_mission.py: |
173 |
'site_id': fields.many2one('cci_missions.site','Site', required=True), |
1609
by qdp
*overall improvement |
174 |
'invoice_date' : fields.datetime('Invoice Date', readonly=True) , |
1541
by Mustufa Rangwala
- add invoice_id on embassy object |
175 |
"invoice_id":fields.many2one("account.invoice","Invoice"), |
1440
by qdp
*spaces replaced by tabulations |
176 |
}
|
177 |
||
178 |
_defaults = { |
|
179 |
'section_id': lambda obj, cr, uid, context: obj.pool.get('crm.case.section').search(cr, uid, [('name','=','Embassy Folder')])[0], |
|
1571
by qdp
*corrected creation of embassy folder from a certificate or legalization |
180 |
'invoice_date': lambda *a: False, |
1557
by qdp
cci_mission.py: |
181 |
'name': lambda *args: '/', |
1567
by Mustufa Rangwala
state field override on embasy folder object (work flow) |
182 |
'state' : lambda *a : 'draft' |
1440
by qdp
*spaces replaced by tabulations |
183 |
}
|
184 |
||
1579
by qdp
*much better use of workflows |
185 |
_constraints = [(check_folder_line, 'Error: Only One Embassy Folder line allowed for each type!', ['embassy_folder_line_ids'])] |
1269
by Mustufa Rangwala
added functionality on embassy folder object (constraint : one folder line for each type) |
186 |
|
1260
by Mustufa Rangwala
add objects(cci_missions_embassy_folder ,cci_missions_embassy_folder_line |
187 |
cci_missions_embassy_folder() |
188 |
||
189 |
class cci_missions_embassy_folder_line (osv.osv): |
|
1440
by qdp
*spaces replaced by tabulations |
190 |
_name = 'cci_missions.embassy_folder_line' |
191 |
_description = 'cci_missions.embassy_folder_line ' |
|
1269
by Mustufa Rangwala
added functionality on embassy folder object (constraint : one folder line for each type) |
192 |
|
2177
by Jay vora
Overridden create and write method for embassy folder lines and changed attribute for account_id. |
193 |
|
194 |
def create(self, cr, uid, vals, *args, **kwargs): |
|
195 |
prod_name= vals['type'] + str(' Product') |
|
196 |
cr.execute('select id from product_template where name='"'%s'"''%str(prod_name)) |
|
197 |
prod=cr.fetchone() |
|
198 |
||
199 |
if prod: |
|
200 |
product_id=prod[0] |
|
201 |
prod_info = self.pool.get('product.product').browse(cr, uid,product_id) |
|
202 |
account = prod_info.product_tmpl_id.property_account_income.id |
|
203 |
if not account: |
|
204 |
account = prod_info.categ_id.property_account_income_categ.id |
|
205 |
vals['account_id']=account |
|
206 |
return super(osv.osv,self).create(cr, uid, vals, *args, **kwargs) |
|
207 |
||
2746
by qdp
*moved the fields for AWEX stuff from cci_translation on embassy_folder_line (+modified the views) |
208 |
def write(self, cr, uid, ids, vals, *args, **kwargs): |
209 |
if vals.has_key('type'): |
|
210 |
prod_name = vals['type'] + str(' Product') |
|
211 |
cr.execute('select id from product_template where name='"'%s'"''%str(prod_name)) |
|
212 |
prod=cr.fetchone() |
|
213 |
if prod: |
|
214 |
product_id=prod[0] |
|
215 |
prod_info = self.pool.get('product.product').browse(cr, uid,product_id) |
|
216 |
account = prod_info.product_tmpl_id.property_account_income.id |
|
217 |
if not account: |
|
218 |
account = prod_info.categ_id.property_account_income_categ.id |
|
219 |
vals['account_id']=account |
|
2177
by Jay vora
Overridden create and write method for embassy folder lines and changed attribute for account_id. |
220 |
return super(osv.osv,self).write( cr, uid, ids,vals, *args, **kwargs) |
221 |
||
1590
by Mustufa Rangwala
*modify embassy folder line (add onchange): |
222 |
def onchange_line_type(self,cr,uid,ids,type): |
1895
by Jay vora
Added onchange_product for cci_mission.embassy_folder_line object. |
223 |
data={} |
224 |
data['courier_cost']=data['customer_amount']=data['account_id']=data['name']=False |
|
1986
by Jay vora
Modified onchange_line)type for object cci_mission_embassy_folder_line,removed product_id field and aded demo data. |
225 |
|
226 |
if not type: |
|
227 |
return {'value' : data } |
|
228 |
||
229 |
data['name']=type |
|
230 |
prod_name= str(type) + str(' Product') |
|
231 |
cr.execute('select id from product_template where name='"'%s'"''%str(prod_name)) |
|
232 |
prod=cr.fetchone() |
|
233 |
||
234 |
if not prod: |
|
235 |
return {'value' : data } |
|
236 |
||
237 |
product_id=prod[0] |
|
1895
by Jay vora
Added onchange_product for cci_mission.embassy_folder_line object. |
238 |
prod_info = self.pool.get('product.product').browse(cr, uid,product_id) |
239 |
data['courier_cost']=prod_info.standard_price |
|
240 |
data['customer_amount']=prod_info.list_price |
|
241 |
account = prod_info.product_tmpl_id.property_account_income.id |
|
242 |
if not account: |
|
243 |
account = prod_info.categ_id.property_account_income_categ.id |
|
244 |
data['account_id']=account |
|
2177
by Jay vora
Overridden create and write method for embassy folder lines and changed attribute for account_id. |
245 |
|
1895
by Jay vora
Added onchange_product for cci_mission.embassy_folder_line object. |
246 |
return {'value' : data } |
247 |
||
1440
by qdp
*spaces replaced by tabulations |
248 |
_columns = { |
249 |
'name' : fields.char('Description',size=50,required=True), |
|
250 |
'folder_id' : fields.many2one('cci_missions.embassy_folder','Related Embassy Folder',required=True), |
|
251 |
'courier_cost' : fields.float('Couriers Costs'), |
|
252 |
'customer_amount' : fields.float('Invoiced Amount'), |
|
1609
by qdp
*overall improvement |
253 |
'tax_rate': fields.many2one('account.tax','Tax Rate'), |
2537
by Mustufa Rangwala
* folder line (fix) |
254 |
'type' : fields.selection([('CBA','CBA'),('Ministry','Ministry'),('Embassy Consulate','Embassy Consulate'),('Translation','Translation'),('Administrative','Administrative'),('Travel Costs','Travel Costs'),('Others','Others')],'Type',required=True), |
2178
by Jay vora
set account_id to required=True for folder lines. |
255 |
'account_id' : fields.many2one('account.account', 'Account',required=True), |
2746
by qdp
*moved the fields for AWEX stuff from cci_translation on embassy_folder_line (+modified the views) |
256 |
'awex_eligible':fields.boolean('AWEX Eligible'), |
257 |
'awex_amount':fields.float('AWEX Amount', readonly=True), |
|
258 |
'credit_line_id':fields.many2one('credit.line', 'Credit Line', readonly=True), |
|
1440
by qdp
*spaces replaced by tabulations |
259 |
}
|
1260
by Mustufa Rangwala
add objects(cci_missions_embassy_folder ,cci_missions_embassy_folder_line |
260 |
|
261 |
cci_missions_embassy_folder_line() |
|
262 |
||
1427
by Mustufa Rangwala
rename 'certificate types' object to 'dossier types' and change according to other objects, |
263 |
class cci_missions_dossier_type(osv.osv): |
1440
by qdp
*spaces replaced by tabulations |
264 |
_name = 'cci_missions.dossier_type' |
265 |
_description = 'cci_missions.dossier_type' |
|
266 |
||
267 |
_columns = { |
|
1726
by qdp
*bugs corrected |
268 |
'code' : fields.char('Code',size=3,required=True), |
269 |
'name' : fields.char('Description',size=50,required=True), |
|
1440
by qdp
*spaces replaced by tabulations |
270 |
'original_product_id' : fields.many2one('product.product','Reference for Original Copies',required=True,help='for the association with a pricelist'), |
271 |
'copy_product_id' : fields.many2one('product.product','Reference for Copies',required=True,help='for the association with a pricelist'), |
|
272 |
'site_id' : fields.many2one('cci_missions.site','Site',required=True), |
|
273 |
'sequence_id' : fields.many2one('ir.sequence','Sequence',required=True,help='for association with a sequence'), |
|
1497
by qdp
*renamed cci_missions in cci_mission |
274 |
'section' : fields.selection([('certificate','Certificate'),('legalization','Legalization'),('ATA','ATA Carnet')],'Type',required=True), |
1595
by Mustufa Rangwala
modify dossier type object (remove required=True) on warranty product 1,2 |
275 |
'warranty_product_1': fields.many2one('product.product', 'Warranty product for ATA carnet if Own Risk'), |
276 |
'warranty_product_2': fields.many2one('product.product', 'Warranty product for ATA carnet if not own Risk'), |
|
2911
by qdp
*applied patch of philmer |
277 |
'id_letter' : fields.char('ID Letter', size=1, help='for identify the type of certificate by the federation' ), |
1440
by qdp
*spaces replaced by tabulations |
278 |
}
|
279 |
||
1427
by Mustufa Rangwala
rename 'certificate types' object to 'dossier types' and change according to other objects, |
280 |
cci_missions_dossier_type() |
1254
by Mustufa Rangwala
add cci_missions_certificate_type,cci_missions.site objects |
281 |
|
1257
by Mustufa Rangwala
add cci_missions_dossier object |
282 |
class cci_missions_dossier(osv.osv): |
1440
by qdp
*spaces replaced by tabulations |
283 |
_name = 'cci_missions.dossier' |
284 |
_description = 'cci_missions.dossier' |
|
285 |
||
286 |
def create(self, cr, uid, vals, *args, **kwargs): |
|
287 |
#overwrite the create: if the text_on_invoice field is empty then fill it with name + destination_id.name + (quantity_original)
|
|
288 |
if not vals['text_on_invoice']: |
|
289 |
invoice_text = vals['name'] |
|
290 |
if vals['destination_id']: |
|
291 |
destination_data = self.pool.get('res.country').browse(cr,uid,vals['destination_id']) |
|
292 |
invoice_text = vals['name'] + ' ' + destination_data.name + ' (' + str(vals['quantity_original']) + ')' |
|
293 |
vals.update({'text_on_invoice': invoice_text}) |
|
294 |
return super(osv.osv,self).create(cr, uid, vals, *args, **kwargs) |
|
295 |
||
296 |
def get_partner_details(self, cr, uid, ids,order_partner_id): |
|
297 |
result={} |
|
298 |
asker_name=False |
|
299 |
sender_name=False |
|
300 |
if order_partner_id: |
|
301 |
partner_info = self.pool.get('res.partner').browse(cr, uid,order_partner_id) |
|
302 |
if not partner_info.asker_name: |
|
303 |
asker_name=partner_info.name |
|
304 |
else: |
|
305 |
asker_name=partner_info.asker_name |
|
306 |
if not partner_info.sender_name: |
|
1500
by qdp
*if a partner has no sender_name define, the onchange now fill the field with the name of the partner |
307 |
sender_name=partner_info.name |
1440
by qdp
*spaces replaced by tabulations |
308 |
else: |
309 |
sender_name=partner_info.sender_name |
|
310 |
result = {'value': { |
|
311 |
'asker_name': asker_name, |
|
312 |
'sender_name': sender_name} |
|
313 |
}
|
|
314 |
return result |
|
315 |
||
316 |
def _amount_subtotal(self, cr, uid, ids, name, args, context=None): |
|
1470
by Jay vora
added product_lines,modified dossier and carnet objects for product_ids field |
317 |
res={} |
1440
by qdp
*spaces replaced by tabulations |
318 |
data_dosseir = self.browse(cr,uid,ids) |
319 |
for data in data_dosseir: |
|
1470
by Jay vora
added product_lines,modified dossier and carnet objects for product_ids field |
320 |
sum=0.00 |
1440
by qdp
*spaces replaced by tabulations |
321 |
for product in data.product_ids: |
1470
by Jay vora
added product_lines,modified dossier and carnet objects for product_ids field |
322 |
sum += product.price_subtotal |
323 |
res[data.id]=sum |
|
1440
by qdp
*spaces replaced by tabulations |
324 |
return res |
325 |
||
326 |
_columns = { |
|
1529
by Mustufa Rangwala
add id field on carnet and dosseir |
327 |
'id': fields.integer('ID', readonly=True), |
1440
by qdp
*spaces replaced by tabulations |
328 |
'name' : fields.char('Reference',size=20,required=True), |
329 |
'type_id' : fields.many2one('cci_missions.dossier_type','Dossier Type',required=True), |
|
330 |
'date' : fields.date('Creation Date',required=True), |
|
331 |
'order_partner_id': fields.many2one('res.partner','Billed Customer',required=True), |
|
332 |
'asker_name':fields.char('Asker Name',size=50), |
|
333 |
'sender_name':fields.char('Sender Name',size=50), |
|
334 |
'to_bill':fields.boolean('To Be Billed'), |
|
1497
by qdp
*renamed cci_missions in cci_mission |
335 |
'state':fields.selection([('draft','Confirmed'),('invoiced','Invoiced'),('cancel_customer','Canceled by Customer'),('cancel_cci','Canceled by the CCI')],'State',), |
1440
by qdp
*spaces replaced by tabulations |
336 |
'goods':fields.char('Goods Description',size=100), |
337 |
'goods_value':fields.float('Value of the Sold Goods'),#Monetary; must be greater than zero |
|
338 |
'destination_id':fields.many2one('res.country','Destination Country'), |
|
339 |
'embassy_folder_id':fields.many2one('cci_missions.embassy_folder','Related Embassy Folder'), |
|
340 |
'quantity_copies':fields.integer('Number of Copies'), |
|
1529
by Mustufa Rangwala
add id field on carnet and dosseir |
341 |
'quantity_original' : fields.integer('Quantity of Originals',required=True), |
1609
by qdp
*overall improvement |
342 |
'sub_total':fields.function(_amount_subtotal, method=True, string='Sub Total for Extra Products', store=True), |
1440
by qdp
*spaces replaced by tabulations |
343 |
'text_on_invoice':fields.text('Text to Display on the Invoice'), |
1470
by Jay vora
added product_lines,modified dossier and carnet objects for product_ids field |
344 |
'product_ids': fields.one2many('product.lines', 'dossier_product_line_id', 'Products'), |
1557
by qdp
cci_mission.py: |
345 |
'invoice_id':fields.many2one("account.invoice","Invoice"), |
346 |
'invoiced_amount': fields.float('Total'), |
|
1440
by qdp
*spaces replaced by tabulations |
347 |
}
|
348 |
||
349 |
_defaults = { |
|
350 |
'name': lambda *args: '/', |
|
351 |
'date': lambda *a: time.strftime('%Y-%m-%d'), |
|
352 |
'to_bill' : lambda *b : True, |
|
1497
by qdp
*renamed cci_missions in cci_mission |
353 |
'state' : lambda *a : 'draft', |
1440
by qdp
*spaces replaced by tabulations |
354 |
'quantity_original' : lambda *a : 1 |
355 |
}
|
|
1260
by Mustufa Rangwala
add objects(cci_missions_embassy_folder ,cci_missions_embassy_folder_line |
356 |
|
357 |
cci_missions_dossier() |
|
358 |
||
359 |
class cci_missions_custom_code(osv.osv): |
|
1440
by qdp
*spaces replaced by tabulations |
360 |
_name= 'cci_missions.custom_code' |
361 |
_desctiption = 'cci_missions.custom_code' |
|
362 |
_columns = { |
|
363 |
'name' : fields.char('Name',size=8,required=True), |
|
364 |
'meaning' : fields.char('Meaning',size=250,required=True), |
|
1609
by qdp
*overall improvement |
365 |
'official' : fields.boolean('Official Code'), |
1440
by qdp
*spaces replaced by tabulations |
366 |
}
|
367 |
||
368 |
_defaults = { |
|
369 |
'official': lambda *a: False, |
|
370 |
}
|
|
1260
by Mustufa Rangwala
add objects(cci_missions_embassy_folder ,cci_missions_embassy_folder_line |
371 |
|
372 |
cci_missions_custom_code() |
|
373 |
||
374 |
class cci_missions_certificate(osv.osv): |
|
1440
by qdp
*spaces replaced by tabulations |
375 |
_name = 'cci_missions.certificate' |
376 |
_description = 'cci_missions.certificate' |
|
377 |
_inherits = {'cci_missions.dossier': 'dossier_id' } |
|
378 |
||
1689
by qdp
*added dependance to sale |
379 |
def _amount_total(self, cr, uid, ids, name, args, context=None): |
380 |
res ={} |
|
381 |
data_dosseir = self.browse(cr,uid,ids) |
|
382 |
||
383 |
for data in data_dosseir: |
|
384 |
if data.state =='draft': |
|
385 |
data_partner = self.pool.get('res.partner').browse(cr,uid,data.order_partner_id.id) |
|
386 |
context.update({'partner_id':data_partner}) |
|
387 |
context.update({'force_member':False}) |
|
388 |
context.update({'force_non_member':False}) |
|
389 |
context.update({'date':data.date}) |
|
390 |
context.update({'value_goods':data.goods_value}) |
|
1788
by Mustufa Rangwala
* now it wll consider pricelist from partner instead of product |
391 |
context.update({'pricelist':data_partner.property_product_pricelist.id}) |
1689
by qdp
*added dependance to sale |
392 |
price_org = self.pool.get('product.product')._product_price(cr, uid, [data.type_id.original_product_id.id], False, False, context) |
393 |
price_copy = self.pool.get('product.product')._product_price(cr, uid, [data.type_id.copy_product_id.id], False, False, context) |
|
394 |
cost_org=price_org[data.type_id.original_product_id.id] |
|
395 |
cost_copy=price_copy[data.type_id.copy_product_id.id] |
|
396 |
qty_org = data.quantity_original |
|
397 |
qty_copy = data.quantity_copies |
|
398 |
subtotal = data.sub_total |
|
399 |
if qty_org < 0 or qty_copy < 0: |
|
400 |
raise osv.except_osv('Input Error!','No. of Copies and Quantity of Originals should be positive.') |
|
401 |
total = ((cost_org * qty_org ) + (cost_copy * qty_copy) + subtotal) |
|
402 |
res[data.id] = total |
|
403 |
else : |
|
404 |
res[data.id]=data.invoiced_amount |
|
405 |
return res |
|
406 |
||
1579
by qdp
*much better use of workflows |
407 |
def cci_dossier_cancel_cci(self, cr, uid, ids, *args): |
1589
by Mustufa Rangwala
*add functionality (modify workflow function): |
408 |
data=self.browse(cr,uid,ids[0]) |
409 |
if data.invoice_id.state == 'paid': |
|
410 |
new_ids = self.pool.get('account.invoice').refund(cr, uid,[data.invoice_id.id]) |
|
411 |
self.write(cr, uid,ids, {'invoice_id' : new_ids[0]}) |
|
412 |
else: |
|
413 |
wf_service = netsvc.LocalService('workflow') |
|
414 |
wf_service.trg_validate(uid, 'account.invoice', data.invoice_id.id, 'invoice_cancel', cr) |
|
1497
by qdp
*renamed cci_missions in cci_mission |
415 |
self.write(cr, uid, ids, {'state':'cancel_cci',}) |
416 |
return True |
|
417 |
||
1440
by qdp
*spaces replaced by tabulations |
418 |
def get_certification_details(self, cr, uid, ids,order_partner_id): |
419 |
result={} |
|
420 |
asker_name=False |
|
421 |
sender_name=False |
|
422 |
asker_address=False |
|
423 |
zip=False |
|
424 |
||
425 |
if order_partner_id: |
|
426 |
partner_info = self.pool.get('res.partner').browse(cr, uid,order_partner_id) |
|
2072
by Mustufa Rangwala
* modify onchange for partner:ata_carnets, certificates, legalizations, embassy_folders |
427 |
if partner_info.alert_legalisations: |
2076
by Mustufa Rangwala
* modify onchange partner |
428 |
raise osv.except_osv('Error!',partner_info.alert_explanation or 'Partner is not valid') |
1440
by qdp
*spaces replaced by tabulations |
429 |
if not partner_info.asker_name: |
430 |
asker_name=partner_info.name |
|
431 |
else: |
|
432 |
asker_name=partner_info.asker_name |
|
433 |
if not partner_info.sender_name: |
|
1500
by qdp
*if a partner has no sender_name define, the onchange now fill the field with the name of the partner |
434 |
sender_name=partner_info.name |
1440
by qdp
*spaces replaced by tabulations |
435 |
else: |
436 |
sender_name=partner_info.sender_name |
|
437 |
if not partner_info.asker_address: |
|
438 |
if partner_info.address!=[]: |
|
439 |
for add in partner_info.address: |
|
440 |
if add.type=='default': |
|
441 |
asker_address=add.street |
|
442 |
break
|
|
443 |
else: |
|
444 |
asker_address=partner_info.asker_address |
|
445 |
if not partner_info.asker_zip_id.id: |
|
446 |
if partner_info.address!=[]: |
|
447 |
for add in partner_info.address: |
|
448 |
if add.type=='default': |
|
449 |
zip=add.zip_id.id |
|
450 |
break
|
|
451 |
else: |
|
452 |
zip=partner_info.asker_zip_id.id |
|
453 |
||
454 |
result = {'value': { |
|
455 |
'asker_name': asker_name, |
|
456 |
'asker_address': asker_address, |
|
457 |
'asker_zip_id': zip, |
|
458 |
'sender_name': sender_name} |
|
459 |
}
|
|
460 |
return result |
|
461 |
||
462 |
def create(self, cr, uid, vals, *args, **kwargs): |
|
463 |
# Overwrite the name fields to set next sequence according to the sequence in the certification type (type_id)
|
|
464 |
if vals['type_id']: |
|
465 |
data = self.pool.get('cci_missions.dossier_type').browse(cr, uid,vals['type_id']) |
|
466 |
seq = self.pool.get('ir.sequence').get(cr, uid,data.sequence_id.code) |
|
467 |
if seq: |
|
468 |
vals.update({'name': seq}) |
|
469 |
return super(osv.osv,self).create(cr, uid, vals, *args, **kwargs) |
|
470 |
||
471 |
_columns = { |
|
472 |
'dossier_id' : fields.many2one('cci_missions.dossier','Dossier'), |
|
1689
by qdp
*added dependance to sale |
473 |
'total':fields.function(_amount_total, method=True, string='Total', store=True),# sum of the price for copies, originals and extra_products |
1440
by qdp
*spaces replaced by tabulations |
474 |
'asker_address' : fields.char('Asker Address',size=50),#by default, res.partner->asker_adress or, res_partner.address[default]->street |
475 |
'asker_zip_id' : fields.many2one('res.partner.zip','Asker Zip Code'),#by default, res.partner->asker_zip_id or, res_partner.address[default]->zip_id |
|
476 |
'special_reason' : fields.selection([('none','None'),('Commercial Reason','Commercial Reason'),('Substitution','Substitution')],'For special cases'), |
|
477 |
'legalization_ids' : fields.one2many('cci_missions.legalization','certificate_id','Related Legalizations'), |
|
478 |
'customs_ids' : fields.many2many('cci_missions.custom_code','certificate_custome_code_rel','certificate_id','custom_id','Custom Codes'), |
|
2773
by qdp
*renamed sending_SPF field into sending_spf field: the capital letters were causing problem and couldn't be accessed in the database |
479 |
'sending_spf': fields.date('SPF Sending Date',help='Date of the sending of this record to the external database'), |
1440
by qdp
*spaces replaced by tabulations |
480 |
'origin_ids' : fields.many2many('res.country','certificate_country_rel','certificate_id','country_id','Origin Countries') |
481 |
}
|
|
482 |
||
483 |
_defaults = { |
|
484 |
'special_reason': lambda *a: 'none', |
|
485 |
}
|
|
1260
by Mustufa Rangwala
add objects(cci_missions_embassy_folder ,cci_missions_embassy_folder_line |
486 |
|
487 |
cci_missions_certificate() |
|
488 |
||
489 |
class cci_missions_legalization(osv.osv): |
|
1440
by qdp
*spaces replaced by tabulations |
490 |
_name = 'cci_missions.legalization' |
491 |
_description = 'cci_missions.legalization' |
|
492 |
_inherits = {'cci_missions.dossier': 'dossier_id'} |
|
493 |
||
1689
by qdp
*added dependance to sale |
494 |
def _amount_total(self, cr, uid, ids, name, args, context=None): |
495 |
res ={} |
|
496 |
data_dosseir = self.browse(cr,uid,ids) |
|
497 |
||
498 |
for data in data_dosseir: |
|
499 |
if data.state =='draft': |
|
500 |
data_partner = self.pool.get('res.partner').browse(cr,uid,data.order_partner_id.id) |
|
501 |
||
502 |
force_member=force_non_member=False |
|
503 |
if data.member_price==1: |
|
504 |
force_member=True |
|
505 |
else: |
|
506 |
force_non_member=True |
|
507 |
context.update({'partner_id':data_partner}) |
|
508 |
context.update({'force_member':force_member}) |
|
509 |
context.update({'force_non_member':force_non_member}) |
|
510 |
context.update({'date':data.date}) |
|
511 |
context.update({'value_goods':data.goods_value}) |
|
1788
by Mustufa Rangwala
* now it wll consider pricelist from partner instead of product |
512 |
context.update({'pricelist':data_partner.property_product_pricelist.id}) |
1689
by qdp
*added dependance to sale |
513 |
price_org = self.pool.get('product.product')._product_price(cr, uid, [data.type_id.original_product_id.id], False, False, context) |
514 |
price_copy = self.pool.get('product.product')._product_price(cr, uid, [data.type_id.copy_product_id.id], False, False, context) |
|
515 |
cost_org=price_org[data.type_id.original_product_id.id] |
|
516 |
cost_copy=price_copy[data.type_id.copy_product_id.id] |
|
517 |
qty_org = data.quantity_original |
|
518 |
qty_copy = data.quantity_copies |
|
519 |
subtotal = data.sub_total |
|
520 |
||
521 |
if qty_org < 0 or qty_copy < 0: |
|
522 |
raise osv.except_osv('Input Error!','No. of Copies and Quantity of Originals should be positive.') |
|
523 |
total = ((cost_org * qty_org ) + (cost_copy * qty_copy) + subtotal) |
|
524 |
res[data.id] = total |
|
525 |
else : |
|
526 |
res[data.id]=data.invoiced_amount |
|
527 |
return res |
|
528 |
||
1579
by qdp
*much better use of workflows |
529 |
def cci_dossier_cancel_cci(self, cr, uid, ids, *args): |
1589
by Mustufa Rangwala
*add functionality (modify workflow function): |
530 |
data=self.browse(cr,uid,ids[0]) |
531 |
if data.invoice_id.state == 'paid': |
|
532 |
new_ids = self.pool.get('account.invoice').refund(cr, uid,[data.invoice_id.id]) |
|
533 |
self.write(cr, uid,ids, {'invoice_id' : new_ids[0]}) |
|
534 |
else: |
|
535 |
wf_service = netsvc.LocalService('workflow') |
|
536 |
wf_service.trg_validate(uid, 'account.invoice', data.invoice_id.id, 'invoice_cancel', cr) |
|
1497
by qdp
*renamed cci_missions in cci_mission |
537 |
self.write(cr, uid, ids, {'state':'cancel_cci',}) |
538 |
return True |
|
539 |
||
1440
by qdp
*spaces replaced by tabulations |
540 |
def get_legalization_details(self, cr, uid, ids,order_partner_id): |
541 |
result={} |
|
542 |
asker_name=False |
|
543 |
sender_name=False |
|
1648
by Mustufa Rangwala
* add onchange on partner_id for ata object |
544 |
member_state=False |
1440
by qdp
*spaces replaced by tabulations |
545 |
if order_partner_id: |
546 |
partner_info = self.pool.get('res.partner').browse(cr, uid,order_partner_id) |
|
2072
by Mustufa Rangwala
* modify onchange for partner:ata_carnets, certificates, legalizations, embassy_folders |
547 |
if partner_info.alert_legalisations: |
2076
by Mustufa Rangwala
* modify onchange partner |
548 |
raise osv.except_osv('Error!',partner_info.alert_explanation or 'Partner is not valid') |
1648
by Mustufa Rangwala
* add onchange on partner_id for ata object |
549 |
if partner_info.membership_state == 'none': #the boolean "Apply the member price" should be set to TRUE or FALSE when the partner is changed in regard of the membership state of him. |
550 |
member_state = False |
|
551 |
else: |
|
552 |
member_state = True |
|
1440
by qdp
*spaces replaced by tabulations |
553 |
if not partner_info.asker_name: |
554 |
asker_name=partner_info.name |
|
555 |
else: |
|
556 |
asker_name=partner_info.asker_name |
|
557 |
if not partner_info.sender_name: |
|
1500
by qdp
*if a partner has no sender_name define, the onchange now fill the field with the name of the partner |
558 |
sender_name=partner_info.name |
1440
by qdp
*spaces replaced by tabulations |
559 |
else: |
560 |
sender_name=partner_info.sender_name |
|
561 |
result = {'value': { |
|
562 |
'asker_name': asker_name, |
|
1648
by Mustufa Rangwala
* add onchange on partner_id for ata object |
563 |
'sender_name': sender_name, |
564 |
'member_price':member_state |
|
565 |
}
|
|
1440
by qdp
*spaces replaced by tabulations |
566 |
}
|
567 |
return result |
|
568 |
||
1458
by qdp
*Add demo data |
569 |
def create(self, cr, uid, vals, *args, **kwargs): |
570 |
# Overwrite the name fields to set next sequence according to the sequence in the legalization type (type_id)
|
|
571 |
if vals['type_id']: |
|
572 |
data = self.pool.get('cci_missions.dossier_type').browse(cr, uid,vals['type_id']) |
|
573 |
seq = self.pool.get('ir.sequence').get(cr, uid,data.sequence_id.code) |
|
574 |
if seq: |
|
575 |
vals.update({'name': seq}) |
|
576 |
return super(osv.osv,self).create(cr, uid, vals, *args, **kwargs) |
|
1440
by qdp
*spaces replaced by tabulations |
577 |
|
1557
by qdp
cci_mission.py: |
578 |
def _get_member_state(self, cr, uid, ids, name, args, context=None): |
579 |
res={} |
|
580 |
leg_ids = self.browse(cr,uid,ids) |
|
581 |
for p_id in leg_ids: |
|
582 |
res[p_id.id]=p_id.dossier_id.order_partner_id.membership_state |
|
583 |
return res |
|
584 |
||
1440
by qdp
*spaces replaced by tabulations |
585 |
_columns = { |
2746
by qdp
*moved the fields for AWEX stuff from cci_translation on embassy_folder_line (+modified the views) |
586 |
'dossier_id' : fields.many2one('cci_missions.dossier','Dossier'), |
1689
by qdp
*added dependance to sale |
587 |
'total':fields.function(_amount_total, method=True, string='Total', store=True),# sum of the price for copies, originals and extra_products |
1440
by qdp
*spaces replaced by tabulations |
588 |
'certificate_id' : fields.many2one('cci_missions.certificate','Related Certificate'), |
1557
by qdp
cci_mission.py: |
589 |
'partner_member_state': fields.function(_get_member_state, method=True,selection=STATE,string='Member State of the Partner',readonly=True,type="selection"), |
590 |
'member_price' : fields.boolean('Apply the Member Price'), |
|
1440
by qdp
*spaces replaced by tabulations |
591 |
}
|
1260
by Mustufa Rangwala
add objects(cci_missions_embassy_folder ,cci_missions_embassy_folder_line |
592 |
|
593 |
cci_missions_legalization() |
|
594 |
||
595 |
class cci_missions_courier_log(osv.osv): |
|
1440
by qdp
*spaces replaced by tabulations |
596 |
_name = 'cci_missions.courier_log' |
597 |
_description = 'cci_missions.courier_log' |
|
598 |
_columns = { |
|
599 |
'embassy_folder_id' : fields.many2one('cci_missions.embassy_folder','Related Embassy Folder',required=True), |
|
600 |
'cba': fields.boolean('CBA'), |
|
601 |
'ministry' : fields.boolean('Ministry'), |
|
602 |
'translation' : fields.boolean('Translation'), |
|
603 |
'embassy_name' : fields.char('Embassy Name',size=30), |
|
604 |
'consulate_name' : fields.char('Consulate Name',size=30), |
|
605 |
'others' : fields.char('Others',size=200), |
|
606 |
'copy_cba' : fields.boolean('Photocopy Before CBA'), |
|
607 |
'copy_ministry' : fields.boolean('Photocopy Before Ministry'), |
|
608 |
'copy_embassy_consulate' : fields.boolean('Photocopy Before Embassy or Consulate'), |
|
609 |
'documents' : fields.integer('Number of Documents to Legalize'), |
|
610 |
'documents_certificate' : fields.text('List of Certificates'), |
|
611 |
'documents_invoice' : fields.text('List of Invoices'), |
|
612 |
'documents_others' : fields.text('Others'), |
|
613 |
'message' : fields.text('Message to the Courier'), |
|
2746
by qdp
*moved the fields for AWEX stuff from cci_translation on embassy_folder_line (+modified the views) |
614 |
'return_address' : fields.selection([('A la CCI','A la CCI'),('Au clent','Au client')],'Address of Return',required=True), |
1440
by qdp
*spaces replaced by tabulations |
615 |
'address_name_1' : fields.char('Company Name',size=80), |
616 |
'address_name_2' : fields.char('Contact Name',size=80), |
|
617 |
'address_street' : fields.char('Street',size=80), |
|
618 |
'address_city' : fields.char('City',size=80), |
|
619 |
'qtty_to_print' : fields.integer('Number of Sheets'), |
|
620 |
'partner_address_id' : fields.many2one('res.partner.address','Courier'), |
|
621 |
}
|
|
1260
by Mustufa Rangwala
add objects(cci_missions_embassy_folder ,cci_missions_embassy_folder_line |
622 |
|
623 |
cci_missions_courier_log() |
|
624 |
||
1415
by Mustufa Rangwala
modify mission site object and add mission area object |
625 |
class cci_missions_area(osv.osv): |
1440
by qdp
*spaces replaced by tabulations |
626 |
_name = 'cci_missions.area' |
627 |
_description = 'cci_missions.area' |
|
628 |
_columns = { |
|
629 |
'name' : fields.char('Description',size=50,required=True,transtale=True), |
|
630 |
'country_ids': fields.many2many('res.country','area_country_rel','area','country',"Countries"), |
|
631 |
}
|
|
1260
by Mustufa Rangwala
add objects(cci_missions_embassy_folder ,cci_missions_embassy_folder_line |
632 |
|
1415
by Mustufa Rangwala
modify mission site object and add mission area object |
633 |
cci_missions_area() |
1417
by Mustufa Rangwala
add ata_usage and letters_log objects |
634 |
|
635 |
class cci_missions_ata_usage(osv.osv): |
|
1440
by qdp
*spaces replaced by tabulations |
636 |
_name = 'cci_missions.ata_usage' |
637 |
_description = 'cci_missions.ata_usage' |
|
638 |
_columns = { |
|
639 |
'name' : fields.char('Usage',size=80,required=True), |
|
640 |
}
|
|
1417
by Mustufa Rangwala
add ata_usage and letters_log objects |
641 |
|
642 |
cci_missions_ata_usage() |
|
1432
by Jay vora
|
643 |
|
1442
by Mustufa Rangwala
validity date as a default (creation_date+1 yr - day), |
644 |
class cci_missions_ata_carnet(osv.osv): |
1449
by qdp
conflicting changes resolved |
645 |
_name = 'cci_missions.ata_carnet' |
646 |
_description = 'cci_missions.ata_carnet' |
|
647 |
||
1726
by qdp
*bugs corrected |
648 |
def create(self, cr, uid, vals, *args, **kwargs): |
649 |
context = {} |
|
1788
by Mustufa Rangwala
* now it wll consider pricelist from partner instead of product |
650 |
data_partner=self.pool.get('res.partner').browse(cr,uid,vals['partner_id']) |
651 |
context.update({'pricelist':data_partner.property_product_pricelist.id}) |
|
652 |
||
1726
by qdp
*bugs corrected |
653 |
if 'creation_date' in vals: |
654 |
context.update({'date':vals['creation_date']}) |
|
2371
by Jay vora
Added context 'emission_date' on carnet object,minor modifications on wizard. |
655 |
context.update({'emission_date':vals['creation_date']}) |
1726
by qdp
*bugs corrected |
656 |
if 'partner_id' in vals: |
657 |
context.update({'partner_id':vals['partner_id']}) |
|
658 |
if 'goods_value' in vals: |
|
659 |
context.update({'value_goods':vals['goods_value']}) |
|
660 |
if 'double_signature' in vals: |
|
661 |
context.update({'double_signature':vals['double_signature']}) |
|
662 |
force_member=force_non_member=False |
|
663 |
if 'member_price' in vals and vals['member_price']==1: |
|
664 |
force_member=True |
|
665 |
else: |
|
666 |
force_non_member=True |
|
667 |
context.update({'force_member':force_member}) |
|
668 |
context.update({'force_non_member':force_non_member}) |
|
669 |
||
670 |
data = self.pool.get('cci_missions.dossier_type').browse(cr, uid,vals['type_id']) |
|
671 |
if 'own_risk' in vals and vals['own_risk']: |
|
672 |
warranty_product = data.warranty_product_1.id |
|
673 |
else: |
|
674 |
warranty_product = data.warranty_product_2.id |
|
675 |
||
676 |
warranty= self.pool.get('product.product').price_get(cr,uid,[warranty_product],'list_price', context)[warranty_product] |
|
677 |
vals.update({'warranty_product_id' : warranty_product, 'warranty': warranty}) |
|
678 |
||
679 |
seq = self.pool.get('ir.sequence').get(cr, uid,data.sequence_id.code) |
|
680 |
if seq: |
|
681 |
vals.update({'name': seq}) |
|
682 |
return super(osv.osv,self).create(cr, uid, vals, *args, **kwargs) |
|
683 |
||
1592
by Mustufa Rangwala
* override write method on ata carnet object |
684 |
def write(self, cr, uid, ids,vals, *args, **kwargs): |
1726
by qdp
*bugs corrected |
685 |
data_carnet = self.browse(cr,uid,ids[0]) |
686 |
context = {} |
|
687 |
if 'creation_date' in vals: |
|
688 |
context.update({'date':vals['creation_date']}) |
|
2371
by Jay vora
Added context 'emission_date' on carnet object,minor modifications on wizard. |
689 |
context.update({'emission_date':vals['creation_date']}) |
1726
by qdp
*bugs corrected |
690 |
else: |
691 |
context.update({'date':data_carnet.creation_date}) |
|
2371
by Jay vora
Added context 'emission_date' on carnet object,minor modifications on wizard. |
692 |
context.update({'emission_date':data_carnet.creation_date}) |
693 |
||
1726
by qdp
*bugs corrected |
694 |
if 'partner_id' in vals: |
695 |
context.update({'partner_id':vals['partner_id']}) |
|
1788
by Mustufa Rangwala
* now it wll consider pricelist from partner instead of product |
696 |
data_partner=self.pool.get('res.partner').browse(cr,uid,vals['partner_id']) |
1726
by qdp
*bugs corrected |
697 |
else: |
1994
by Jay vora
Minor modification for write method of ata_carnet object. |
698 |
context.update({'partner_id':data_carnet.partner_id.id}) |
699 |
data_partner=self.pool.get('res.partner').browse(cr,uid,data_carnet.partner_id.id) |
|
700 |
||
1726
by qdp
*bugs corrected |
701 |
if 'goods_value' in vals: |
702 |
context.update({'value_goods':vals['goods_value']}) |
|
703 |
else: |
|
704 |
context.update({'value_goods':data_carnet.goods_value}) |
|
705 |
if 'double_signature' in vals: |
|
706 |
context.update({'double_signature':vals['double_signature']}) |
|
707 |
else: |
|
708 |
context.update({'double_signature':data_carnet.double_signature}) |
|
709 |
force_member=force_non_member=False |
|
1994
by Jay vora
Minor modification for write method of ata_carnet object. |
710 |
|
1788
by Mustufa Rangwala
* now it wll consider pricelist from partner instead of product |
711 |
context.update({'pricelist':data_partner.property_product_pricelist.id}) |
1726
by qdp
*bugs corrected |
712 |
if 'member_price' in vals: |
713 |
if vals['member_price']==1: |
|
714 |
force_member=True |
|
715 |
else: |
|
716 |
force_non_member=True |
|
717 |
else: |
|
718 |
if data_carnet.member_price==1: |
|
719 |
force_member=True |
|
720 |
else: |
|
721 |
force_non_member=True |
|
722 |
context.update({'force_member':force_member}) |
|
723 |
context.update({'force_non_member':force_non_member}) |
|
724 |
||
725 |
if 'own_risk' in vals: |
|
726 |
if vals['own_risk']: |
|
727 |
warranty_product = data_carnet.type_id.warranty_product_1.id |
|
728 |
else: |
|
729 |
warranty_product = data_carnet.type_id.warranty_product_2.id |
|
730 |
else: |
|
731 |
if data_carnet.own_risk: |
|
732 |
warranty_product = data_carnet.type_id.warranty_product_1.id |
|
733 |
else: |
|
734 |
warranty_product = data_carnet.type_id.warranty_product_2.id |
|
735 |
warranty= self.pool.get('product.product').price_get(cr,uid,[warranty_product],'list_price', context)[warranty_product] |
|
736 |
||
737 |
vals.update({'warranty_product_id' : warranty_product, 'warranty': warranty}) |
|
1592
by Mustufa Rangwala
* override write method on ata carnet object |
738 |
super(cci_missions_ata_carnet,self).write(cr, uid, ids,vals, *args, **kwargs) |
739 |
return True |
|
740 |
||
1497
by qdp
*renamed cci_missions in cci_mission |
741 |
def button_uncertain(self, cr, uid, ids, *args): |
742 |
self.write(cr, uid, ids, {'state':'pending',}) |
|
743 |
return True |
|
744 |
||
745 |
def button_correct(self, cr, uid, ids, *args): |
|
1500
by qdp
*if a partner has no sender_name define, the onchange now fill the field with the name of the partner |
746 |
self.write(cr, uid, ids, {'state':'correct','ok_state_date':time.strftime('%Y-%m-%d')}) |
1497
by qdp
*renamed cci_missions in cci_mission |
747 |
return True |
748 |
||
749 |
def button_dispute(self, cr, uid, ids, *args): |
|
750 |
self.write(cr, uid, ids, {'state':'dispute',}) |
|
751 |
return True |
|
752 |
||
753 |
def button_closed(self, cr, uid, ids, *args): |
|
754 |
self.write(cr, uid, ids, {'state':'closed',}) |
|
755 |
return True |
|
756 |
||
1500
by qdp
*if a partner has no sender_name define, the onchange now fill the field with the name of the partner |
757 |
def cci_ata_created(self, cr, uid, ids): |
758 |
self.write(cr, uid, ids, {'state':'created','return_date':time.strftime('%Y-%m-%d')}) |
|
759 |
return True |
|
760 |
||
1449
by qdp
conflicting changes resolved |
761 |
def _get_insurer_id(self, cr, uid, ids, name, args, context=None): |
762 |
res={} |
|
763 |
partner_ids = self.browse(cr,uid,ids) |
|
764 |
for p_id in partner_ids: |
|
765 |
res[p_id.id]=p_id.partner_id.insurer_id |
|
766 |
return res |
|
767 |
||
1657
by Mustufa Rangwala
* add onchange for own_ridk on ata carnet |
768 |
def onchange_type_carnet(self, cr, uid, ids,type_id,own_risk): |
1698
by Jay vora
on Ata_carnet : added onchange of warranty product id and modified on change of type id and own risk accordingly,set warranty to readony=true. |
769 |
data={'warranty_product_id' : False,'warranty':False} |
1585
by Mustufa Rangwala
*put onchange on type_id (ata carnet object) : |
770 |
if not type_id: |
1698
by Jay vora
on Ata_carnet : added onchange of warranty product id and modified on change of type id and own risk accordingly,set warranty to readony=true. |
771 |
return {'value':data} |
1585
by Mustufa Rangwala
*put onchange on type_id (ata carnet object) : |
772 |
data_carnet_type = self.pool.get('cci_missions.dossier_type').browse(cr,uid,type_id) |
1657
by Mustufa Rangwala
* add onchange for own_ridk on ata carnet |
773 |
if own_risk: |
1698
by Jay vora
on Ata_carnet : added onchange of warranty product id and modified on change of type id and own risk accordingly,set warranty to readony=true. |
774 |
warranty_prod=data_carnet_type.warranty_product_1.id |
1657
by Mustufa Rangwala
* add onchange for own_ridk on ata carnet |
775 |
else: |
1698
by Jay vora
on Ata_carnet : added onchange of warranty product id and modified on change of type id and own risk accordingly,set warranty to readony=true. |
776 |
warranty_prod=data_carnet_type.warranty_product_2.id |
777 |
data['warranty_product_id'] =warranty_prod |
|
778 |
dict1=self.onchange_warranty_product_id(cr,uid,ids,warranty_prod) |
|
779 |
data.update(dict1['value']) |
|
780 |
return {'value':data} |
|
1657
by Mustufa Rangwala
* add onchange for own_ridk on ata carnet |
781 |
|
782 |
def onchange_own_risk(self,cr,uid,ids,type_id,own_risk): |
|
1698
by Jay vora
on Ata_carnet : added onchange of warranty product id and modified on change of type id and own risk accordingly,set warranty to readony=true. |
783 |
data={'warranty_product_id' : False,'warranty':False} |
1657
by Mustufa Rangwala
* add onchange for own_ridk on ata carnet |
784 |
if not type_id: |
1698
by Jay vora
on Ata_carnet : added onchange of warranty product id and modified on change of type id and own risk accordingly,set warranty to readony=true. |
785 |
return {'value': data} |
1657
by Mustufa Rangwala
* add onchange for own_ridk on ata carnet |
786 |
warranty_prod = False |
787 |
data_carnet_type = self.pool.get('cci_missions.dossier_type').browse(cr,uid,type_id) |
|
788 |
if own_risk: |
|
789 |
warranty_prod =data_carnet_type.warranty_product_1.id |
|
790 |
else: |
|
791 |
warranty_prod = data_carnet_type.warranty_product_2.id |
|
1698
by Jay vora
on Ata_carnet : added onchange of warranty product id and modified on change of type id and own risk accordingly,set warranty to readony=true. |
792 |
data['warranty_product_id'] =warranty_prod |
793 |
dict1=self.onchange_warranty_product_id(cr,uid,ids,warranty_prod) |
|
794 |
data.update(dict1['value']) |
|
795 |
return {'value':data} |
|
1657
by Mustufa Rangwala
* add onchange for own_ridk on ata carnet |
796 |
|
1449
by qdp
conflicting changes resolved |
797 |
def _get_member_state(self, cr, uid, ids, name, args, context=None): |
798 |
res={} |
|
799 |
partner_ids = self.browse(cr,uid,ids) |
|
800 |
for p_id in partner_ids: |
|
801 |
res[p_id.id]=p_id.partner_id.membership_state |
|
802 |
return res |
|
803 |
||
804 |
def check_ata_carnet(self,cr, uid, ids): |
|
805 |
data_carnet=self.browse(cr, uid, ids) |
|
806 |
for data in data_carnet: |
|
807 |
if (data.own_risk) or (data.insurer_agreement > 0 and data.partner_id.insurer_id > 0): |
|
808 |
return True |
|
809 |
return False |
|
810 |
||
811 |
def _default_validity_date(self,cr,uid,context={}): |
|
812 |
creation_date=datetime.datetime.today() |
|
813 |
year=datetime.date(creation_date.year + 1,creation_date.month,creation_date.day) |
|
814 |
validity_date= year - timedelta(days=1) |
|
815 |
return validity_date.strftime('%Y-%m-%d') |
|
816 |
||
1470
by Jay vora
added product_lines,modified dossier and carnet objects for product_ids field |
817 |
def _tot_products(self, cr, uid, ids, name, args, context=None): |
818 |
res={} |
|
819 |
carnet_ids = self.browse(cr,uid,ids) |
|
820 |
for p_id in carnet_ids: |
|
821 |
sum=0.00 |
|
822 |
for line_id in p_id.product_ids: |
|
823 |
sum += line_id.price_subtotal |
|
824 |
res[p_id.id]=sum |
|
825 |
return res |
|
826 |
||
1648
by Mustufa Rangwala
* add onchange on partner_id for ata object |
827 |
def onchange_partner_id(self,cr,uid,ids,partner_id): |
828 |
#the boolean "Apply the member price" should be set to TRUE or FALSE when the partner is changed in regard of the membership state of him.
|
|
829 |
member_state = False |
|
830 |
if partner_id: |
|
831 |
partner_info = self.pool.get('res.partner').browse(cr, uid,partner_id) |
|
2072
by Mustufa Rangwala
* modify onchange for partner:ata_carnets, certificates, legalizations, embassy_folders |
832 |
if partner_info.alert_legalisations: |
2076
by Mustufa Rangwala
* modify onchange partner |
833 |
raise osv.except_osv('Error!',partner_info.alert_explanation or 'Partner is not valid') |
1648
by Mustufa Rangwala
* add onchange on partner_id for ata object |
834 |
if partner_info.membership_state == 'none': |
835 |
member_state = False |
|
836 |
else: |
|
837 |
member_state = True |
|
838 |
return {'value':{'member_price' : member_state}} |
|
839 |
||
1698
by Jay vora
on Ata_carnet : added onchange of warranty product id and modified on change of type id and own risk accordingly,set warranty to readony=true. |
840 |
def onchange_warranty_product_id(self,cr,uid,ids,prod_id): |
841 |
warranty_price= False |
|
842 |
if prod_id: |
|
843 |
prod_info = self.pool.get('product.product').browse(cr, uid,prod_id) |
|
844 |
warranty_price=prod_info.list_price |
|
845 |
return {'value':{'warranty' : warranty_price}} |
|
846 |
||
1449
by qdp
conflicting changes resolved |
847 |
_columns = { |
1529
by Mustufa Rangwala
add id field on carnet and dosseir |
848 |
'id': fields.integer('ID', readonly=True), |
1449
by qdp
conflicting changes resolved |
849 |
'type_id' : fields.many2one('cci_missions.dossier_type','Related Type of Carnet',required=True), |
1609
by qdp
*overall improvement |
850 |
'creation_date' : fields.date('Emission Date',required=True), |
1449
by qdp
conflicting changes resolved |
851 |
'validity_date' : fields.date('Validity Date',required=True), |
852 |
'partner_id': fields.many2one('res.partner','Partner',required=True), |
|
853 |
'holder_name' : fields.char('Holder Name',size=50), |
|
854 |
'holder_address' : fields.char('Holder Address',size=50), |
|
855 |
'holder_city' : fields.char('Holder City',size=50), |
|
856 |
'representer_name' : fields.char('Representer Name',size=50), |
|
857 |
'representer_address' : fields.char('Representer Address',size=50), |
|
858 |
'representer_city' : fields.char('Representer City',size=50), |
|
859 |
'usage_id': fields.many2one('cci_missions.ata_usage','Usage',required=True), |
|
860 |
'goods': fields.char('Goods',size=80), |
|
861 |
'area_id': fields.many2one('cci_missions.area','Area',required=True), |
|
1649
by Mustufa Rangwala
*on partner : |
862 |
'insurer_agreement' : fields.char('Insurer Agreement',size=50), |
1449
by qdp
conflicting changes resolved |
863 |
'own_risk' : fields.boolean('Own Risks'), |
864 |
'goods_value': fields.float('Goods Value',required=True), |
|
865 |
'double_signature' : fields.boolean('Double Signature'), |
|
866 |
'initial_pages' : fields.integer('Initial Number of Pages',required=True), |
|
867 |
'additional_pages' : fields.integer('Additional Number of Pages'), |
|
1698
by Jay vora
on Ata_carnet : added onchange of warranty product id and modified on change of type id and own risk accordingly,set warranty to readony=true. |
868 |
'warranty':fields.float('Warranty',readonly=True), |
1449
by qdp
conflicting changes resolved |
869 |
'warranty_product_id': fields.many2one('product.product','Related Warranty Product',required=True), |
870 |
'return_date' : fields.date('Date of Return'), |
|
871 |
'state':fields.selection([('draft','Draft'),('created','Created'),('pending','Pending'),('dispute','Dispute'),('correct','Correct'),('closed','Closed')],'State',required=True,readonly=True), |
|
872 |
'ok_state_date' : fields.date('Date of Closure'), |
|
1543
by qdp
* user_id on crm.case.log is now uid by default |
873 |
'federation_sending_date' : fields.date('Date of Sending to the Federation', readonly=True), |
1449
by qdp
conflicting changes resolved |
874 |
'name' : fields.char('Name',size=50,required=True), |
875 |
'partner_insurer_id': fields.function(_get_insurer_id, method=True,string='Insurer ID of the Partner',readonly=True), |
|
876 |
'partner_member_state': fields.function(_get_member_state, method=True,selection=STATE,string='Member State of the Partner',readonly=True,type="selection"), |
|
877 |
'member_price' : fields.boolean('Apply the Member Price'), |
|
1470
by Jay vora
added product_lines,modified dossier and carnet objects for product_ids field |
878 |
'product_ids': fields.one2many('product.lines', 'product_line_id', 'Products'), |
1449
by qdp
conflicting changes resolved |
879 |
'letter_ids':fields.one2many('cci_missions.letters_log','ata_carnet_id','Letters'), |
1470
by Jay vora
added product_lines,modified dossier and carnet objects for product_ids field |
880 |
'sub_total': fields.function(_tot_products, method=True, string='Subtotal of Extra Products',type="float"), |
1497
by qdp
*renamed cci_missions in cci_mission |
881 |
"invoice_id":fields.many2one("account.invoice","Invoice"), |
1449
by qdp
conflicting changes resolved |
882 |
}
|
883 |
||
884 |
_defaults = { |
|
885 |
'own_risk' : lambda *b : False, |
|
886 |
'double_signature' : lambda *b : False, |
|
887 |
'state' : lambda *a : 'draft', |
|
888 |
'validity_date' : _default_validity_date, |
|
889 |
'name': lambda *args: '/', |
|
1529
by Mustufa Rangwala
add id field on carnet and dosseir |
890 |
'creation_date': lambda *a: time.strftime('%Y-%m-%d'), |
1449
by qdp
conflicting changes resolved |
891 |
}
|
1585
by Mustufa Rangwala
*put onchange on type_id (ata carnet object) : |
892 |
_constraints = [(check_ata_carnet, 'Error: Please Select (Own Risk) OR ("Insurer Agreement" and "Parnters Insure id" should be greater than Zero)', ['own_risk','insurer_agreement','partner_insurer_id'])] |
1442
by Mustufa Rangwala
validity date as a default (creation_date+1 yr - day), |
893 |
|
894 |
cci_missions_ata_carnet() |
|
1432
by Jay vora
|
895 |
|
896 |
class cci_missions_letters_log(osv.osv): |
|
1449
by qdp
conflicting changes resolved |
897 |
_name = 'cci_missions.letters_log' |
898 |
_description = 'cci_missions.letters_log' |
|
899 |
_rec_name = 'date' |
|
900 |
_columns = { |
|
1440
by qdp
*spaces replaced by tabulations |
901 |
'ata_carnet_id' : fields.many2one('cci_missions.ata_carnet','Related ATA Carnet',required=True), |
902 |
'letter_type' : fields.selection([('Rappel avant echeance','Rappel avant echeance'),('Rappel apres echeance','Rappel apres echeance'),('Suite lettre A','Suite lettre A'),('Suite lettre C','Suite lettre C'),('Suite lettre C1','Suite lettre C1'),('Suite lettre I','Suite lettre I'),('Demande de remboursement','Demande de remboursement'),('Rappel a remboursement','Rappel a remboursement'),('Mise en demeure','Mise en demeure')],'Type of Letter',required=True), |
|
903 |
'date' : fields.date('Date of Sending',required=True), |
|
904 |
}
|
|
1449
by qdp
conflicting changes resolved |
905 |
_defaults = { |
1440
by qdp
*spaces replaced by tabulations |
906 |
'date': lambda *args: time.strftime('%Y-%m-%d') |
907 |
}
|
|
1432
by Jay vora
|
908 |
|
909 |
cci_missions_letters_log() |
|
910 |
||
1470
by Jay vora
added product_lines,modified dossier and carnet objects for product_ids field |
911 |
class product_lines(osv.osv): |
912 |
_name = "product.lines" |
|
913 |
_description = "Product Lines" |
|
914 |
||
1758
by Mustufa Rangwala
* on extra_products (ata, certificates and legalization) the product is now mandatory and the account_id field has to be removed in order to make the view simplrer for the final user (have to overwrite create and write) |
915 |
def create(self, cr, uid, vals, *args, **kwargs): |
916 |
if vals['product_id']: |
|
917 |
accnt_dict = {} |
|
918 |
data_product = self.pool.get('product.product').browse(cr,uid,vals['product_id']) |
|
919 |
a = data_product.product_tmpl_id.property_account_income.id |
|
920 |
if not a: |
|
921 |
a = data_product.categ_id.property_account_income_categ.id |
|
922 |
accnt_dict['account_id']=a |
|
923 |
vals.update(accnt_dict) |
|
924 |
return super(product_lines,self).create(cr, uid, vals, *args, **kwargs) |
|
925 |
||
926 |
def write(self, cr, uid, ids,vals, *args, **kwargs): |
|
927 |
data_product_line= self.pool.get('product.lines').browse(cr,uid,ids[0]) |
|
928 |
if (not data_product_line.product_id.id == vals['product_id']): |
|
929 |
accnt_dict = {} |
|
930 |
data_product = self.pool.get('product.product').browse(cr,uid,vals['product_id']) |
|
931 |
a = data_product.product_tmpl_id.property_account_income.id |
|
932 |
if not a: |
|
933 |
a = data_product.categ_id.property_account_income_categ.id |
|
934 |
accnt_dict['account_id']=a |
|
935 |
vals.update(accnt_dict) |
|
936 |
return super(product_lines,self).write( cr, uid, ids,vals, *args, **kwargs) |
|
937 |
||
1470
by Jay vora
added product_lines,modified dossier and carnet objects for product_ids field |
938 |
def _product_subtotal(self, cr, uid, ids, name, args, context=None): |
939 |
res = {} |
|
940 |
for line in self.browse(cr, uid, ids): |
|
941 |
res[line.id] = round(line.price_unit * line.quantity) |
|
942 |
return res |
|
943 |
||
1726
by qdp
*bugs corrected |
944 |
def product_id_change(self, cr, uid, ids,product_id,): |
1758
by Mustufa Rangwala
* on extra_products (ata, certificates and legalization) the product is now mandatory and the account_id field has to be removed in order to make the view simplrer for the final user (have to overwrite create and write) |
945 |
price_unit=uos_id=prod_name=data_partner=False |
1470
by Jay vora
added product_lines,modified dossier and carnet objects for product_ids field |
946 |
if product_id: |
947 |
data_product = self.pool.get('product.product').browse(cr,uid,product_id) |
|
948 |
uos_id=data_product.uom_id.id |
|
1726
by qdp
*bugs corrected |
949 |
price=self.pool.get('product.product').price_get(cr,uid,[product_id]) |
1655
by Jay vora
Modified price_get call from _amount_total function under dossier object and modified product_id_change function behaviour under product_lines object |
950 |
price_unit=price[product_id] |
1478
by qdp
*_amount_total() now take in consideration the membership of the partner |
951 |
prod_name=data_product.name |
1470
by Jay vora
added product_lines,modified dossier and carnet objects for product_ids field |
952 |
return {'value': { |
953 |
'uos_id': uos_id, |
|
1478
by qdp
*_amount_total() now take in consideration the membership of the partner |
954 |
'price_unit': price_unit, |
1639
by Mustufa Rangwala
* modity onchange_product on product lines: |
955 |
'name':prod_name, |
956 |
}
|
|
1470
by Jay vora
added product_lines,modified dossier and carnet objects for product_ids field |
957 |
}
|
958 |
||
959 |
_columns = { |
|
960 |
'name': fields.char('Description', size=256, required=True), |
|
961 |
'product_line_id': fields.many2one('cci_missions.ata_carnet', 'Product Ref',select=True), |
|
962 |
'dossier_product_line_id': fields.many2one('cci_missions.dossier', 'Product Ref',select=True), |
|
963 |
'uos_id': fields.many2one('product.uom', 'Unit', ondelete='set null'), |
|
1772
by Mustufa Rangwala
modify product lines (make product field mandatory for leg.) |
964 |
'product_id': fields.many2one('product.product', 'Product', ondelete='set null',required=True), |
1470
by Jay vora
added product_lines,modified dossier and carnet objects for product_ids field |
965 |
'price_unit': fields.float('Unit Price', required=True, digits=(16,2)), |
966 |
'price_subtotal': fields.function(_product_subtotal, method=True, string='Subtotal'), |
|
967 |
'quantity': fields.float('Quantity', required=True), |
|
1581
by qdp
*creation of invoice for certifiacte ans legalization corrected |
968 |
'account_id' : fields.many2one('account.account', 'Account', required=True), |
1470
by Jay vora
added product_lines,modified dossier and carnet objects for product_ids field |
969 |
}
|
970 |
_defaults = { |
|
971 |
'quantity': lambda *a: 1, |
|
972 |
}
|
|
973 |
product_lines() |
|
1689
by qdp
*added dependance to sale |
974 |
|
975 |
||
976 |
class Product(osv.osv): |
|
977 |
'''Product'''
|
|
978 |
_inherit = 'product.product' |
|
979 |
||
1691
by qdp
*modified the function price_get that will have to be corrected in order to match the criteria grid of the CCI |
980 |
#this function will have to be corrected in order to match the criteria grid of the CCI
|
1689
by qdp
*added dependance to sale |
981 |
def price_get(self, cr, uid, ids, ptype='list_price',context={}): |
2562
by qdp
*added the compution of price for member, overwritting of price_get method of product_product |
982 |
|
983 |
res = {} |
|
984 |
product_uom_obj = self.pool.get('product.uom') |
|
985 |
# force_member works for forcing member price if partner is non member, same reasonning for force_non_member
|
|
986 |
for product in self.browse(cr, uid, ids, context=context): |
|
987 |
if ptype == 'member_price': |
|
988 |
res[product.id] = product['list_price'] |
|
989 |
if context and ('partner_id' in context): |
|
2929
by qdp
*bugfix: the priceget method of the product receive an ID and not a browse_record |
990 |
state = self.pool.get('res.partner').browse(cr, uid, [context['partner_id']])[0].membership_state |
2562
by qdp
*added the compution of price for member, overwritting of price_get method of product_product |
991 |
if (state in ['waiting','associated','free','paid','invoiced']): |
992 |
res[product.id] = product['member_price'] |
|
993 |
if context and ('force_member' in context): |
|
994 |
if context['force_member']: |
|
995 |
res[product.id] = product['member_price'] |
|
996 |
if context and ('force_non_member' in context): |
|
997 |
if context['force_non_member']: |
|
998 |
res[product.id] = product['list_price'] |
|
999 |
else: |
|
1000 |
res[product.id] = product[ptype] or 0.0 |
|
1001 |
if ptype == 'list_price': |
|
1002 |
res[product.id] = (res[product.id] * product.price_margin) + \ |
|
1003 |
product.price_extra |
|
1004 |
if 'uom' in context: |
|
1005 |
uom = product.uos_id or product.uom_id |
|
1006 |
res[product.id] = product_uom_obj._compute_price(cr, uid, |
|
1007 |
uom.id, res[product.id], context['uom']) |
|
1008 |
||
1009 |
for product in self.browse(cr, uid, ids, context=context): |
|
1726
by qdp
*bugs corrected |
1010 |
#change the price only for ATA originals
|
1011 |
if product.name.find('ATA - original') != -1: |
|
1691
by qdp
*modified the function price_get that will have to be corrected in order to match the criteria grid of the CCI |
1012 |
if context and ('value_goods' in context): |
1726
by qdp
*bugs corrected |
1013 |
if context['value_goods'] < 25000: |
1014 |
res[product.id] = res[product.id] + context['value_goods']*0.008903875 |
|
1015 |
elif 25000 <= context['value_goods'] < 75000 : |
|
1016 |
res[product.id] = res[product.id] + context['value_goods']*0.006937375 |
|
1017 |
elif 75000 <= context['value_goods'] < 250000 : |
|
1018 |
res[product.id] = res[product.id] + context['value_goods']*0.004446475 |
|
1691
by qdp
*modified the function price_get that will have to be corrected in order to match the criteria grid of the CCI |
1019 |
else: |
1726
by qdp
*bugs corrected |
1020 |
res[product.id] = res[product.id] + context['value_goods']*0.002764025 |
1021 |
if context and ('double_signature' in context): |
|
1022 |
if context['double_signature'] == False: |
|
1023 |
res[product.id] = res[product.id] + 5.45 |
|
1024 |
||
1025 |
#change the price only for warranty own risk on ATA carnet
|
|
1026 |
if product.name.find('ATA - Own Risk Warranty') != -1: |
|
1027 |
if context and ('value_goods' in context): |
|
1028 |
if context['value_goods'] > 15000: |
|
1029 |
res[product.id] = round(context['value_goods']*0.03) |
|
1030 |
||
1689
by qdp
*added dependance to sale |
1031 |
return res |
1032 |
||
1033 |
Product() |
|
1034 |