models.py 25 KB

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