models.py 22 KB

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