models.py 24 KB

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