Created
June 16, 2016 16:09
-
-
Save diegomichell/7c62c6fdec5c4c8d428bc1f0b5310d0e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomPosOrder(models.Model): | |
_inherit = 'pos.order' | |
pass | |
# Quiero implementar sobreescribir el metodo aqui en lugar de en CustomLegacyPosOrder | |
class CustomLegacyPosOrder(osv.osv): | |
""" | |
Made for overriding the odoo 8 pos.order _amount_all method, so that legal tip is included in total | |
""" | |
_name = 'pos.order' | |
_inherit = 'pos.order' | |
def _amount_all(self, cr, uid, ids, name, args, context=None): | |
res = super(CustomLegacyPosOrder, self)._amount_all(cr, uid, ids, name, args, context) | |
for order in self.browse(cr, uid, ids, context=context): | |
amount_untaxed = 0 | |
for line in order.lines: | |
amount_untaxed += line.price_subtotal | |
cr.execute('SELECT using_legal_tip FROM pos_order WHERE id = ' + str(order.id)) | |
using_legal_tip = cr.fetchone()[0] | |
print 'Total Amount: ' + str(res[order.id]['amount_total']) | |
if using_legal_tip: | |
res[order.id]['amount_total'] += amount_untaxed * 0.10 | |
print 'Total Amount With Legal Tip: ' + str(res[order.id]['amount_total']) | |
return res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment