models.py 24 KB

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