models.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809
  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 getResPartner(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. })
  446. return values
  447. class ProductProduct(models.Model):
  448. _inherit = 'product.product'
  449. ############################################################
  450. # PRODUCT PRODUCT
  451. ############################################################
  452. @api.model
  453. def getProductProduct(self,domain):
  454. ProductProduct = self.env['product.product'].search(domain)
  455. values = []
  456. for product in ProductProduct:
  457. attributeValuesLines = map(lambda x: x.id, product.attribute_value_ids)
  458. attributeIDS = []
  459. for arttIds in self.env['product.attribute.value'].search([('id', 'in', attributeValuesLines)]):
  460. attributeIDS.append(arttIds.attribute_id.id)
  461. try:
  462. # sale list price
  463. sale_price = map(lambda x: x.id, product.pricelists)
  464. saleIDS = []
  465. for item in self.env['product.pricelist'].search([('id', 'in', sale_price)]):
  466. saleIDS.append(item.id)
  467. # purchase list price
  468. buy_price = map(lambda x: x.id, product.purchase_pricelists)
  469. buyIDS = []
  470. for item in self.env['product.pricelist'].search([('id', 'in', buy_price)]):
  471. buyIDS.append(item.id)
  472. except:
  473. buyIDS = []
  474. saleIDS = []
  475. try:
  476. brand = product.product_brand_id.id
  477. except:
  478. brand = ''
  479. values.append({
  480. 'id': product.id,
  481. 'name': product.name,
  482. 'display_name': product.display_name,
  483. 'standard_price': product.standard_price,
  484. 'lst_price': product.lst_price,
  485. 'categ_id': {
  486. 'id': product.categ_id.id,
  487. 'name': product.categ_id.name,
  488. 'complete_name': product.categ_id.complete_name,
  489. },
  490. 'product_brand_id':brand,
  491. 'atribute_value_ids': attributeValuesLines,
  492. 'attribute_ids': attributeIDS,
  493. 'qty_available': product.qty_available,
  494. 'default_code': product.default_code,
  495. 'image_medium': product.image_medium,
  496. 'pricelists': saleIDS,
  497. 'purchase_pricelists':buyIDS,
  498. 'product_tmpl_id': product.product_tmpl_id.id,
  499. 'image': product.image,
  500. 'ean13': product.ean13,
  501. })
  502. return values
  503. ############################################################
  504. # PRODUCT PRODUCT - STOCK 'minimo_quantity': product.minimo_quantity,
  505. ############################################################
  506. @api.model
  507. def getProductProductStock(self,domain):
  508. ProductProduct = self.env['product.product'].search(domain)
  509. values = []
  510. for product in ProductProduct:
  511. attributeValuesLines = map(lambda x: x.id, product.attribute_value_ids)
  512. attributeIDS = []
  513. for arttIds in self.env['product.attribute.value'].search([('id', 'in', attributeValuesLines)]):
  514. attributeIDS.append(arttIds.attribute_id.id)
  515. values.append({
  516. 'id': product.id,
  517. 'display_name': product.display_name,
  518. 'standard_price': product.standard_price,
  519. 'lst_price': product.lst_price,
  520. 'categ_id': {
  521. 'id': product.categ_id.id,
  522. 'name': product.categ_id.name,
  523. 'complete_name': product.categ_id.complete_name,
  524. },
  525. 'atribute_value_ids': attributeValuesLines,
  526. 'attribute_ids': attributeIDS,
  527. 'default_code': product.default_code,
  528. 'ean13': product.ean13,
  529. })
  530. return values
  531. ############################################################
  532. # PRODUCT BRAND
  533. ############################################################
  534. @api.model
  535. def getProductBrand(self,domain):
  536. ProductBrand = self.env['product.brand'].search(domain)
  537. values = []
  538. for brand in ProductBrand:
  539. values.append({
  540. 'id': brand.id,
  541. 'name': brand.name,
  542. })
  543. return values
  544. class ProductCategory(models.Model):
  545. _inherit = 'product.category'
  546. @api.model
  547. def getProductCategory(self,domain):
  548. ProductCategory = self.env['product.category'].search(domain)
  549. values = []
  550. for category in ProductCategory:
  551. values.append({
  552. 'id': category.id,
  553. 'name': category.name,
  554. 'display_name': category.display_name,
  555. 'parent_id': [
  556. category.parent_id.id,
  557. category.parent_id.name,
  558. ],
  559. })
  560. return values
  561. class ProductAttribute(models.Model):
  562. _inherit = 'product.attribute'
  563. @api.model
  564. def getProductAttribute(self,domain):
  565. ProductAttribute = self.env['product.attribute'].search(domain)
  566. values = []
  567. for attribute in ProductAttribute:
  568. values.append({
  569. 'id': attribute.id,
  570. 'name': attribute.name,
  571. })
  572. return values
  573. class ProductAttributeValue(models.Model):
  574. _inherit = 'product.attribute.value'
  575. @api.model
  576. def getProductAttributeValue(self,domain):
  577. ProductAttributeValue = self.env['product.attribute.value'].search(domain)
  578. values = []
  579. for value in ProductAttributeValue:
  580. values.append({
  581. 'id': value.id,
  582. 'name': value.name,
  583. 'attribute_id': [
  584. value.attribute_id.id,
  585. value.attribute_id.name,
  586. ],
  587. })
  588. return values
  589. class StockLocation(models.Model):
  590. _inherit = 'stock.location'
  591. @api.model
  592. def getStockLocation(self,domain):
  593. StockLocation = self.env['stock.location'].search(domain)
  594. values = []
  595. for location in StockLocation:
  596. values.append({
  597. 'id': location.id,
  598. 'name': location.name,
  599. 'display_name': location.display_name,
  600. 'parent_name': location.location_id.name,
  601. 'company_id': [
  602. location.company_id.id,
  603. location.company_id.name,
  604. ],
  605. 'store_id': [
  606. location.store_id.id,
  607. location.store_id.name,
  608. ],
  609. 'usage': location.usage,
  610. })
  611. return values
  612. class StockQuant(models.Model):
  613. _inherit = 'stock.quant'
  614. @api.model
  615. def getStockQuant(self,domain):
  616. StockQuant = self.env['stock.quant'].search(domain)
  617. values = []
  618. for quant in StockQuant:
  619. values.append({
  620. 'id': quant.id,
  621. 'name': quant.name,
  622. 'display_name': quant.display_name,
  623. 'location_id': [
  624. quant.location_id.id,
  625. quant.location_id.name,
  626. ],
  627. 'product_id': [
  628. quant.product_id.id,
  629. quant.product_id.name,
  630. ],
  631. 'qty': quant.qty,
  632. })
  633. return values
  634. class StockMove(models.Model):
  635. _inherit = 'stock.move'
  636. @api.model
  637. def getStockMove(self,domain):
  638. StockMove = self.env['stock.move'].search(domain)
  639. values = []
  640. for move in StockMove:
  641. values.append({
  642. 'id': move.id,
  643. 'create_date' : move.create_date,
  644. 'name': move.name,
  645. 'state' : move.state,
  646. 'location_id': {
  647. 'id' : move.location_id.id,
  648. 'complete_name' : move.location_id.complete_name,
  649. 'store_id' : move.location_id.store_id.id,
  650. },
  651. 'location_dest_id': {
  652. 'id' : move.location_dest_id.id,
  653. 'complete_name' : move.location_dest_id.complete_name,
  654. 'store_id' : move.location_dest_id.store_id.id,
  655. },
  656. 'origin' : move.origin,
  657. 'picking_id' : {
  658. 'id' : move.picking_id.id,
  659. 'name' : move.picking_id.name,
  660. },
  661. 'partner_id' : {
  662. 'id' : move.partner_id.id,
  663. 'name' : move.partner_id.name,
  664. },
  665. 'product_id': {
  666. 'id' : move.product_id.id,
  667. 'display_name' : move.product_id.display_name,
  668. },
  669. 'product_uom_qty': move.product_uom_qty,
  670. })
  671. return values
  672. class StockPicking(models.Model):
  673. _inherit = 'stock.picking'
  674. @api.model
  675. def getStockPicking(self,domain):
  676. StockPicking = self.env['stock.picking'].search(domain)
  677. values = []
  678. for picking in StockPicking:
  679. values.append({
  680. 'id' : picking.id,
  681. 'date' : picking.create_date,
  682. 'name' : picking.name,
  683. 'state' : picking.state,
  684. 'partner_id' : {
  685. 'id' : picking.partner_id.id,
  686. 'name' : picking.partner_id.name,
  687. },
  688. 'move_type' : picking.move_type,
  689. 'picking_type_id' : {
  690. 'id' : picking.picking_type_id.id,
  691. 'name' : picking.picking_type_id.name,
  692. },
  693. 'date_done' : picking.date_done,
  694. 'priority' : picking.priority,
  695. })
  696. return values
  697. class ProductPriceList(models.Model):
  698. _inherit = 'product.pricelist'
  699. @api.model
  700. def getProductPriceList(self,domain):
  701. ProductPriceList = self.env['product.pricelist'].search(domain)
  702. values = []
  703. for pricelist in ProductPriceList:
  704. version_ids = map(lambda x: x.id, pricelist.version_id)
  705. versionIDS = []
  706. for item in self.env['product.pricelist'].search([('id', 'in', version_ids)]):
  707. versionIDS.append(item.id)
  708. values.append({
  709. 'id' : pricelist.id,
  710. 'name' : pricelist.name,
  711. 'type' : pricelist.type,
  712. 'version_id' : versionIDS,
  713. 'store_id' : {
  714. 'id' : pricelist.store_id.id,
  715. 'name' : pricelist.store_id.name,
  716. },
  717. 'currency_id' : {
  718. 'id' : pricelist.currency_id.id,
  719. 'name' : pricelist.currency_id.name,
  720. 'rate_silent': pricelist.currency_id.rate_silent,
  721. },
  722. })
  723. return values