models.py 24 KB

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