models.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api
  3. class AccountInvoice(models.Model):
  4. _inherit = 'account.invoice'
  5. ############################################################
  6. # ACCOUNT INVOICE
  7. ############################################################
  8. @api.model
  9. def getAccountInvoice(self,domain):
  10. AccountInvoice = self.env['account.invoice'].search(domain)
  11. decimal_precision = self.env['decimal.precision'].precision_get('Account')
  12. values = []
  13. for invoice in AccountInvoice:
  14. values.append({
  15. 'id': invoice.id,
  16. 'type': invoice.type,
  17. 'state': invoice.state,
  18. 'number': invoice.number,
  19. 'journal_id': [
  20. invoice.journal_id.id,
  21. invoice.journal_id.name
  22. ],
  23. 'journal_type': invoice.journal_id.type,
  24. 'invoice_currency': [
  25. invoice.currency_id.id,
  26. invoice.currency_id.name,
  27. invoice.currency_id.rate
  28. ],
  29. 'company_currency': [
  30. invoice.company_id.currency_id.id,
  31. invoice.company_id.currency_id.name,
  32. invoice.company_id.currency_id.rate
  33. ],
  34. 'date_invoice': invoice.date_invoice,
  35. 'partner_id': [
  36. invoice.partner_id.id,
  37. invoice.partner_id.name,
  38. invoice.partner_id.ruc,
  39. ],
  40. 'partner_info': {
  41. 'mobile': invoice.partner_id.mobile,
  42. 'phone': invoice.partner_id.phone,
  43. },
  44. 'supplier_invoice_number': invoice.supplier_invoice_number,
  45. 'user_id': [
  46. invoice.user_id.id,
  47. invoice.user_id.name
  48. ],
  49. 'period_id': [
  50. invoice.period_id.id,
  51. invoice.period_id.name
  52. ],
  53. 'amount_untaxed': invoice.amount_untaxed,
  54. 'origin': invoice.origin,
  55. 'residual': invoice.residual,
  56. 'amount_tax': invoice.amount_tax,
  57. 'amount_total': invoice.amount_total,
  58. 'amount_untaxed_currency': invoice.amount_untaxed * (invoice.company_id.currency_id.rate / invoice.currency_id.rate),
  59. 'residual_currency': invoice.residual * (invoice.company_id.currency_id.rate / invoice.currency_id.rate),
  60. 'amount_tax_currency': invoice.amount_tax * (invoice.company_id.currency_id.rate / invoice.currency_id.rate),
  61. 'amount_total_currency': invoice.amount_total * (invoice.company_id.currency_id.rate / invoice.currency_id.rate),
  62. })
  63. return values
  64. ############################################################
  65. # POS ORDER
  66. ############################################################
  67. @api.model
  68. def getPosOrder(self,domain):
  69. PosOrder = self.env['pos.order'].search(domain)
  70. decimal_precision = self.env['decimal.precision'].precision_get('Account')
  71. values = []
  72. for order in PosOrder:
  73. values.append({
  74. 'id': order.id,
  75. 'name': order.name,
  76. 'date_order': order.date_order,
  77. 'pricelist_id':[
  78. order.pricelist_id.id,
  79. order.pricelist_id.name,
  80. ],
  81. 'sale_journal':[
  82. order.sale_journal.id,
  83. order.sale_journal.name,
  84. ],
  85. 'partner_id': [
  86. order.partner_id.id,
  87. order.partner_id.name,
  88. order.partner_id.ruc,
  89. ],
  90. 'user_id': [
  91. order.user_id.id,
  92. order.user_id.name
  93. ],
  94. 'session_id': [
  95. order.session_id.id,
  96. order.session_id.name
  97. ],
  98. 'order_currency': [
  99. order.pricelist_id.currency_id.id,
  100. order.pricelist_id.currency_id.name,
  101. order.pricelist_id.currency_id.rate
  102. ],
  103. 'company_currency': [
  104. order.company_id.currency_id.id,
  105. order.company_id.currency_id.name,
  106. order.company_id.currency_id.rate
  107. ],
  108. 'amount_tax': order.amount_tax,
  109. 'amount_total': order.amount_total,
  110. 'amount_tax_currency': order.amount_tax * (order.company_id.currency_id.rate / order.pricelist_id.currency_id.rate),
  111. 'amount_total_currency': order.amount_total * (order.company_id.currency_id.rate / order.pricelist_id.currency_id.rate),
  112. })
  113. return values
  114. class AccountInvoiceLine(models.Model):
  115. _inherit = 'account.invoice.line'
  116. ############################################################
  117. # ACCOUNT INVOICE LINE
  118. ############################################################
  119. @api.model
  120. def getAccountInvoiceLine(self,domain):
  121. AccountInvoiceLine = self.env['account.invoice.line'].search(domain)
  122. decimal_precision = self.env['decimal.precision'].precision_get('Account')
  123. values = []
  124. for line in AccountInvoiceLine:
  125. values.append({
  126. 'id': line.id,
  127. 'invoice_id':line.invoice_id.id,
  128. 'number':line.invoice_id.number,
  129. 'supplier_invoice_number':line.invoice_id.supplier_invoice_number,
  130. 'date_invoice': line.invoice_id.date_invoice,
  131. 'user_id': [
  132. line.invoice_id.user_id.id,
  133. line.invoice_id.user_id.name,
  134. ],
  135. 'partner_id': [
  136. line.invoice_id.partner_id.id,
  137. line.invoice_id.partner_id.name,
  138. line.invoice_id.partner_id.ruc,
  139. ],
  140. 'store_id': [
  141. line.invoice_id.journal_id.store_ids.id,
  142. line.invoice_id.journal_id.store_ids.name,
  143. ],
  144. 'period_id': [
  145. line.invoice_id.period_id.id,
  146. line.invoice_id.period_id.name,
  147. ],
  148. 'journal_id': [
  149. line.invoice_id.journal_id.id,
  150. line.invoice_id.journal_id.name,
  151. ],
  152. 'invoice_state': line.invoice_id.state,
  153. 'journal_type': line.invoice_id.journal_id.type,
  154. 'invoice_type': line.invoice_id.type,
  155. 'product_id': [
  156. line.product_id.id,
  157. line.product_id.display_name,
  158. line.product_id.categ_id.complete_name,
  159. line.product_id.standard_price,
  160. ],
  161. 'product_category_id': line.product_id.categ_id.id,
  162. 'price_unit': line.price_unit,
  163. 'price_subtotal': line.price_subtotal,
  164. 'quantity': line.quantity,
  165. 'company_currency':[
  166. line.invoice_id.company_id.currency_id.id,
  167. line.invoice_id.company_id.currency_id.name,
  168. line.invoice_id.company_id.currency_id.rate,
  169. ],
  170. 'invoice_currency':[
  171. line.invoice_id.currency_id.id,
  172. line.invoice_id.currency_id.name,
  173. line.invoice_id.currency_id.rate,
  174. ],
  175. 'price_unit_currency': round(line.price_unit * (line.invoice_id.company_id.currency_id.rate / line.invoice_id.currency_id.rate),decimal_precision),
  176. 'price_subtotal_currency': round(line.price_subtotal * (line.invoice_id.company_id.currency_id.rate / line.invoice_id.currency_id.rate),decimal_precision),
  177. 'tax_currency': round((line.price_unit * (line.invoice_id.company_id.currency_id.rate / line.invoice_id.currency_id.rate) * line.quantity) - line.price_subtotal * (line.invoice_id.company_id.currency_id.rate / line.invoice_id.currency_id.rate),decimal_precision),
  178. 'amount_currency': round((line.quantity * line.price_unit) * (line.invoice_id.company_id.currency_id.rate / line.invoice_id.currency_id.rate),decimal_precision),
  179. })
  180. return values
  181. ############################################################
  182. # POS ORDER LINE
  183. ############################################################
  184. @api.model
  185. def getPosOrderLine(self,domain):
  186. PosOrderLine = self.env['pos.order.line'].search(domain)
  187. decimal_precision = self.env['decimal.precision'].precision_get('Account')
  188. values = []
  189. for line in PosOrderLine:
  190. values.append({
  191. 'id': line.id,
  192. 'order_id': [
  193. line.order_id.id,
  194. line.order_id.name
  195. ],
  196. 'product_id': [
  197. line.product_id.id,
  198. line.product_id.display_name,
  199. line.product_id.standard_price,
  200. ],
  201. 'store_id': [
  202. line.order_id.sale_journal.store_ids.id,
  203. line.order_id.sale_journal.store_ids.name,
  204. ],
  205. 'sale_journal': [
  206. line.order_id.sale_journal.id,
  207. line.order_id.sale_journal.name,
  208. ],
  209. 'qty': line.qty,
  210. 'create_date': line.create_date,
  211. 'user_id': [
  212. line.order_id.user_id.id,
  213. line.order_id.user_id.name
  214. ],
  215. 'partner_id': [
  216. line.order_id.partner_id.id,
  217. line.order_id.partner_id.name,
  218. ],
  219. 'company_currency':[
  220. line.order_id.company_id.currency_id.id,
  221. line.order_id.company_id.currency_id.name,
  222. line.order_id.company_id.currency_id.rate,
  223. ],
  224. 'order_currency':[
  225. line.order_id.pricelist_id.currency_id.id,
  226. line.order_id.pricelist_id.currency_id.name,
  227. line.order_id.pricelist_id.currency_id.rate,
  228. ],
  229. 'price_unit': line.price_unit,
  230. 'price_subtotal': line.price_subtotal,
  231. 'price_subtotal_incl': line.price_subtotal_incl,
  232. 'price_unit_currency': round(line.price_unit * (line.order_id.company_id.currency_id.rate / line.order_id.pricelist_id.currency_id.rate),decimal_precision),
  233. 'price_subtotal_currency': round(line.price_subtotal * (line.order_id.company_id.currency_id.rate / line.order_id.pricelist_id.currency_id.rate),decimal_precision),
  234. 'price_subtotal_incl_currency': round(line.price_subtotal_incl * (line.order_id.company_id.currency_id.rate / line.order_id.pricelist_id.currency_id.rate),decimal_precision),
  235. # 'amount_currency': round(line.price_subtotal_incl * (line.order_id.company_id.currency_id.rate / line.order_id.pricelist_id.currency_id.rate),decimal_precision)
  236. })
  237. return values
  238. class AccountJournal(models.Model):
  239. _inherit = 'account.journal'
  240. @api.model
  241. def getAccountJournal(self,domain):
  242. AccountJournal = self.env['account.journal'].search(domain)
  243. values = []
  244. for journal in AccountJournal:
  245. if(journal.currency):
  246. complete_name = journal.name + ' (' + journal.currency.local_name + ')'
  247. else:
  248. complete_name = journal.name + ' (' + journal.company_id.currency_id.local_name + ')'
  249. values.append({
  250. 'id': journal.id,
  251. 'name': journal.name,
  252. 'complete_name': complete_name,
  253. 'type': journal.type,
  254. 'store_ids': [
  255. journal.store_ids.id,
  256. journal.store_ids.name,
  257. ],
  258. 'company_id': [
  259. journal.company_id.id,
  260. journal.company_id.name
  261. ],
  262. 'currency': [
  263. journal.currency.id,
  264. journal.currency.name
  265. ],
  266. })
  267. return values
  268. class AccountBankStatementLine(models.Model):
  269. _inherit = 'account.bank.statement.line'
  270. @api.model
  271. def getAccountBankStatementLine(self,domain):
  272. AccountBankStatementLine = self.env['account.bank.statement.line'].search(domain)
  273. decimal_precision = self.env['decimal.precision'].precision_get('Account')
  274. values = []
  275. for line in AccountBankStatementLine:
  276. try:
  277. pos_statement_id = line.pos_statement_id.id
  278. partner_id = [line.partner_id.id,line.partner_id.name]
  279. except:
  280. pos_statement_id = ''
  281. partner_id = ''
  282. if(line.journal_id.currency):
  283. amount_currency = round(line.amount * (line.company_id.currency_id.rate / line.journal_id.currency.rate),decimal_precision),
  284. else:
  285. amount_currency = line.amount
  286. values.append({
  287. 'id': line.id,
  288. 'name': line.name,
  289. 'date': line.date,
  290. 'partner_id': partner_id,
  291. 'ref': line.ref,
  292. 'currency_id': [
  293. line.currency_id.id,
  294. line.currency_id.name,
  295. ],
  296. 'journal_id': [
  297. line.journal_id.id,
  298. line.journal_id.name,
  299. ],
  300. 'pos_statement_id': pos_statement_id,
  301. 'amount': line.amount,
  302. 'amount': line.amount_currency,
  303. 'amount_currency': amount_currency
  304. })
  305. return values
  306. class AccountMoveLine(models.Model):
  307. _inherit = 'account.move.line'
  308. @api.model
  309. def getAccountMoveLine(self,domain):
  310. AccountMoveLine = self.env['account.move.line'].search(domain)
  311. decimal_precision = self.env['decimal.precision'].precision_get('Account')
  312. values = []
  313. for line in AccountMoveLine:
  314. values.append({
  315. 'id': line.id,
  316. 'name': line.name,
  317. 'date': line.date,
  318. 'date_maturity': line.date_maturity,
  319. 'reconcile_ref': line.reconcile_ref,
  320. 'amount_residual': line.amount_residual,
  321. 'partner_id': [
  322. line.partner_id.id,
  323. line.partner_id.name,
  324. ],
  325. 'move_id': [
  326. line.move_id.id,
  327. line.move_id.name,
  328. ],
  329. 'account_id': [
  330. line.account_id.id,
  331. line.account_id.name,
  332. ],
  333. 'journal_id': [
  334. line.journal_id.id,
  335. line.journal_id.name,
  336. ],
  337. 'debit': line.debit,
  338. 'credit': line.credit,
  339. })
  340. return values
  341. class AccountAccount(models.Model):
  342. _inherit = 'account.account'
  343. @api.model
  344. def getAccountAccount(self,domain):
  345. AccountAccount = self.env['account.account'].search(domain)
  346. values = []
  347. for account in AccountAccount:
  348. values.append({
  349. 'id': account.id,
  350. 'name': account.name,
  351. })
  352. return values
  353. class ResCompany(models.Model):
  354. _inherit = 'res.company'
  355. @api.model
  356. def getResCompany(self,domain):
  357. ResCompany = self.env['res.company'].search(domain)
  358. values = []
  359. for company in ResCompany:
  360. values.append({
  361. 'id': company.id,
  362. 'name': company.name,
  363. 'currency_id': [
  364. company.currency_id.id,
  365. company.currency_id.name,
  366. ],
  367. 'company_ruc': company.partner_id.ruc,
  368. 'phone': company.phone,
  369. 'logo': company.logo,
  370. })
  371. return values
  372. class AccountVoucher(models.Model):
  373. _inherit = 'account.voucher'
  374. @api.model
  375. def getAccountVoucher(self,domain):
  376. AccountVoucher = self.env['account.voucher'].search(domain)
  377. values = []
  378. for voucher in AccountVoucher:
  379. values.append({
  380. 'id': voucher.id,
  381. 'number': voucher.number,
  382. 'create_uid': voucher.create_uid.name,
  383. 'partner_id': [
  384. voucher.partner_id.id,
  385. voucher.partner_id.name,
  386. ],
  387. 'journal_id': [
  388. voucher.journal_id.id,
  389. voucher.journal_id.name,
  390. ],
  391. 'period_id': [
  392. voucher.period_id.id,
  393. voucher.period_id.name,
  394. ],
  395. 'currency_id': [
  396. voucher.currency_id.id,
  397. voucher.currency_id.name,
  398. ],
  399. 'reference': voucher.reference,
  400. 'date': voucher.date,
  401. 'amount': voucher.amount,
  402. 'amount_currency': voucher.amount * (voucher.company_id.currency_id.rate / voucher.currency_id.rate),
  403. })
  404. return values
  405. class ResCurrency(models.Model):
  406. _inherit = 'res.currency'
  407. @api.model
  408. def getResCurrency(self,domain):
  409. ResCurrency = self.env['res.currency'].search(domain)
  410. values = []
  411. for currency in ResCurrency:
  412. values.append({
  413. 'id': currency.id,
  414. 'name': currency.name,
  415. 'symbol': currency.symbol,
  416. 'rate_silent': currency.rate_silent,
  417. 'base': currency.base,
  418. 'decimal_separator': currency.decimal_separator,
  419. 'decimal_places': currency.decimal_places,
  420. 'thousands_separator': currency.thousands_separator,
  421. 'symbol_position': currency.symbol_position,
  422. })
  423. return values
  424. class ResPartner(models.Model):
  425. _inherit = 'res.partner'
  426. @api.model
  427. def getResPartnerSmile(self,domain):
  428. ResPartner = self.env['res.partner'].search(domain)
  429. values = []
  430. for partner in ResPartner:
  431. values.append({
  432. 'id': partner.id,
  433. 'name': partner.name,
  434. 'ruc': partner.ruc,
  435. 'street': partner.street,
  436. 'city': partner.city,
  437. 'phone': partner.phone,
  438. 'mobile': partner.mobile,
  439. 'email': partner.email,
  440. 'property_product_pricelist': partner.property_product_pricelist.name,
  441. 'property_product_pricelist_purchase': partner.property_product_pricelist_purchase.name,
  442. 'credit': partner.credit,
  443. 'debit': partner.debit,
  444. 'supplier': partner.supplier,
  445. 'is_medic': partner.is_medic,
  446. 'medic': [
  447. partner.medic.id,
  448. partner.medic.name,
  449. ],
  450. })
  451. return values
  452. class ProductProduct(models.Model):
  453. _inherit = 'product.product'
  454. ############################################################
  455. # PRODUCT PRODUCT
  456. ############################################################
  457. @api.model
  458. def getProductProduct(self,domain):
  459. ProductProduct = self.env['product.product'].search(domain)
  460. values = []
  461. for product in ProductProduct:
  462. attributeValuesLines = map(lambda x: x.id, product.attribute_value_ids)
  463. attributeIDS = []
  464. for arttIds in self.env['product.attribute.value'].search([('id', 'in', attributeValuesLines)]):
  465. attributeIDS.append(arttIds.attribute_id.id)
  466. try:
  467. # sale list price
  468. sale_price = map(lambda x: x.id, product.pricelists)
  469. saleIDS = []
  470. for item in self.env['product.pricelist'].search([('id', 'in', sale_price)]):
  471. saleIDS.append(item.id)
  472. # purchase list price
  473. buy_price = map(lambda x: x.id, product.purchase_pricelists)
  474. buyIDS = []
  475. for item in self.env['product.pricelist'].search([('id', 'in', buy_price)]):
  476. buyIDS.append(item.id)
  477. except:
  478. buyIDS = []
  479. saleIDS = []
  480. try:
  481. brand = product.product_brand_id.id
  482. except:
  483. brand = ''
  484. values.append({
  485. 'id': product.id,
  486. 'name': product.name,
  487. 'display_name': product.display_name,
  488. 'standard_price': product.standard_price,
  489. 'lst_price': product.lst_price,
  490. 'categ_id': {
  491. 'id': product.categ_id.id,
  492. 'name': product.categ_id.name,
  493. 'complete_name': product.categ_id.complete_name,
  494. },
  495. 'product_brand_id':brand,
  496. 'atribute_value_ids': attributeValuesLines,
  497. 'attribute_ids': attributeIDS,
  498. 'qty_available': product.qty_available,
  499. 'default_code': product.default_code,
  500. 'image_medium': product.image_medium,
  501. 'pricelists': saleIDS,
  502. 'purchase_pricelists':buyIDS,
  503. 'product_tmpl_id': product.product_tmpl_id.id,
  504. 'image': product.image,
  505. 'ean13': product.ean13,
  506. })
  507. return values
  508. ############################################################
  509. # PRODUCT PRODUCT - STOCK 'minimo_quantity': product.minimo_quantity,
  510. ############################################################
  511. @api.model
  512. def getProductProductStock(self,domain):
  513. ProductProduct = self.env['product.product'].search(domain)
  514. values = []
  515. for product in ProductProduct:
  516. attributeValuesLines = map(lambda x: x.id, product.attribute_value_ids)
  517. attributeIDS = []
  518. for arttIds in self.env['product.attribute.value'].search([('id', 'in', attributeValuesLines)]):
  519. attributeIDS.append(arttIds.attribute_id.id)
  520. values.append({
  521. 'id': product.id,
  522. 'display_name': product.display_name,
  523. 'standard_price': product.standard_price,
  524. 'lst_price': product.lst_price,
  525. 'categ_id': {
  526. 'id': product.categ_id.id,
  527. 'name': product.categ_id.name,
  528. 'complete_name': product.categ_id.complete_name,
  529. },
  530. 'atribute_value_ids': attributeValuesLines,
  531. 'attribute_ids': attributeIDS,
  532. 'default_code': product.default_code,
  533. 'ean13': product.ean13,
  534. })
  535. return values
  536. ############################################################
  537. # PRODUCT BRAND
  538. ############################################################
  539. @api.model
  540. def getProductBrand(self,domain):
  541. ProductBrand = self.env['product.brand'].search(domain)
  542. values = []
  543. for brand in ProductBrand:
  544. values.append({
  545. 'id': brand.id,
  546. 'name': brand.name,
  547. })
  548. return values
  549. class ProductCategory(models.Model):
  550. _inherit = 'product.category'
  551. @api.model
  552. def getProductCategory(self,domain):
  553. ProductCategory = self.env['product.category'].search(domain)
  554. values = []
  555. for category in ProductCategory:
  556. values.append({
  557. 'id': category.id,
  558. 'name': category.name,
  559. 'display_name': category.display_name,
  560. 'parent_id': [
  561. category.parent_id.id,
  562. category.parent_id.name,
  563. ],
  564. })
  565. return values
  566. class ProductAttribute(models.Model):
  567. _inherit = 'product.attribute'
  568. @api.model
  569. def getProductAttribute(self,domain):
  570. ProductAttribute = self.env['product.attribute'].search(domain)
  571. values = []
  572. for attribute in ProductAttribute:
  573. values.append({
  574. 'id': attribute.id,
  575. 'name': attribute.name,
  576. })
  577. return values
  578. class ProductAttributeValue(models.Model):
  579. _inherit = 'product.attribute.value'
  580. @api.model
  581. def getProductAttributeValue(self,domain):
  582. ProductAttributeValue = self.env['product.attribute.value'].search(domain)
  583. values = []
  584. for value in ProductAttributeValue:
  585. values.append({
  586. 'id': value.id,
  587. 'name': value.name,
  588. 'attribute_id': [
  589. value.attribute_id.id,
  590. value.attribute_id.name,
  591. ],
  592. })
  593. return values
  594. class StockLocation(models.Model):
  595. _inherit = 'stock.location'
  596. @api.model
  597. def getStockLocation(self,domain):
  598. StockLocation = self.env['stock.location'].search(domain)
  599. values = []
  600. for location in StockLocation:
  601. values.append({
  602. 'id': location.id,
  603. 'name': location.name,
  604. 'display_name': location.display_name,
  605. 'parent_name': location.location_id.name,
  606. 'company_id': [
  607. location.company_id.id,
  608. location.company_id.name,
  609. ],
  610. 'store_id': [
  611. location.store_id.id,
  612. location.store_id.name,
  613. ],
  614. 'usage': location.usage,
  615. })
  616. return values
  617. class StockQuant(models.Model):
  618. _inherit = 'stock.quant'
  619. @api.model
  620. def getStockQuant(self,domain):
  621. StockQuant = self.env['stock.quant'].search(domain)
  622. values = []
  623. for quant in StockQuant:
  624. values.append({
  625. 'id': quant.id,
  626. 'name': quant.name,
  627. 'display_name': quant.display_name,
  628. 'location_id': [
  629. quant.location_id.id,
  630. quant.location_id.name,
  631. ],
  632. 'product_id': [
  633. quant.product_id.id,
  634. quant.product_id.name,
  635. ],
  636. 'qty': quant.qty,
  637. })
  638. return values
  639. class StockMove(models.Model):
  640. _inherit = 'stock.move'
  641. @api.model
  642. def getStockMove(self,domain):
  643. StockMove = self.env['stock.move'].search(domain)
  644. values = []
  645. for move in StockMove:
  646. values.append({
  647. 'id': move.id,
  648. 'create_date' : move.create_date,
  649. 'name': move.name,
  650. 'state' : move.state,
  651. 'location_id': {
  652. 'id' : move.location_id.id,
  653. 'complete_name' : move.location_id.complete_name,
  654. 'store_id' : move.location_id.store_id.id,
  655. },
  656. 'location_dest_id': {
  657. 'id' : move.location_dest_id.id,
  658. 'complete_name' : move.location_dest_id.complete_name,
  659. 'store_id' : move.location_dest_id.store_id.id,
  660. },
  661. 'origin' : move.origin,
  662. 'picking_id' : {
  663. 'id' : move.picking_id.id,
  664. 'name' : move.picking_id.name,
  665. },
  666. 'partner_id' : {
  667. 'id' : move.partner_id.id,
  668. 'name' : move.partner_id.name,
  669. },
  670. 'product_id': {
  671. 'id' : move.product_id.id,
  672. 'display_name' : move.product_id.display_name,
  673. },
  674. 'product_uom_qty': move.product_uom_qty,
  675. })
  676. return values
  677. class StockPicking(models.Model):
  678. _inherit = 'stock.picking'
  679. @api.model
  680. def getStockPicking(self,domain):
  681. StockPicking = self.env['stock.picking'].search(domain)
  682. values = []
  683. for picking in StockPicking:
  684. values.append({
  685. 'id' : picking.id,
  686. 'date' : picking.create_date,
  687. 'name' : picking.name,
  688. 'state' : picking.state,
  689. 'partner_id' : {
  690. 'id' : picking.partner_id.id,
  691. 'name' : picking.partner_id.name,
  692. },
  693. 'move_type' : picking.move_type,
  694. 'picking_type_id' : {
  695. 'id' : picking.picking_type_id.id,
  696. 'name' : picking.picking_type_id.name,
  697. },
  698. 'date_done' : picking.date_done,
  699. 'priority' : picking.priority,
  700. })
  701. return values
  702. class ProductPriceList(models.Model):
  703. _inherit = 'product.pricelist'
  704. @api.model
  705. def getProductPriceList(self,domain):
  706. ProductPriceList = self.env['product.pricelist'].search(domain)
  707. values = []
  708. for pricelist in ProductPriceList:
  709. version_ids = map(lambda x: x.id, pricelist.version_id)
  710. versionIDS = []
  711. for item in self.env['product.pricelist'].search([('id', 'in', version_ids)]):
  712. versionIDS.append(item.id)
  713. values.append({
  714. 'id' : pricelist.id,
  715. 'name' : pricelist.name,
  716. 'type' : pricelist.type,
  717. 'version_id' : versionIDS,
  718. 'store_id' : {
  719. 'id' : pricelist.store_id.id,
  720. 'name' : pricelist.store_id.name,
  721. },
  722. 'currency_id' : {
  723. 'id' : pricelist.currency_id.id,
  724. 'name' : pricelist.currency_id.name,
  725. 'rate_silent': pricelist.currency_id.rate_silent,
  726. },
  727. })
  728. return values