def test_invoice(self):
        self.account_invoice.search([('id', '=', self.invoice.id)])
        self.invoice.draft_blocked = True

        workflow.trg_validate(self.uid, 'account.invoice', self.invoice.id,
                              'invoice_open', self.cr)
        move_line = self.account_move_line.search([
            ('account_id.user_type_id', 'in',
             [self.type_recv.id, self.type_payable.id]),
            ('invoice_id', '=', self.invoice.id)
        ])
        if move_line:
            self.assertTrue(move_line[0].blocked)
            self.assertEqual(self.invoice.blocked, move_line[0].blocked,
                             'Blocked values are not equals')
            move_line[0].blocked = False
            self.invoice = self.account_invoice.search([('id', '=',
                                                         self.invoice.id)])
            self.assertEqual(self.invoice.blocked, move_line[0].blocked,
                             'Blocked values are not equals')
            self.invoice.blocked = True
            self.invoice = self.account_invoice.search([('id', '=',
                                                         self.invoice.id)])
            self.assertEqual(self.invoice.blocked, move_line[0].blocked,
                             'Blocked values are not equals')
Example #2
0
    def setUp(self):
        super(TestAccountDueListDaysOverdue, self).setUp()
        self.overdue_term_model = self.env['account.overdue.term']
        self.account_user_type = self.env.\
            ref('account.data_account_type_receivable')
        self.revenue_user_type = self.env.\
            ref('account.data_account_type_revenue')
        self.account = self.env['account.account']
        self.account_move_line_model = self.env['account.move.line']
        self.account_invoice_model = self.env['account.invoice']
        self.account_invoice_line_model = self.env['account.invoice.line']
        self.overdue_term_1 = self.env.ref(
            'account_due_list_days_overdue.overdue_term_1')
        self.partner_agrolait = self.env.ref('base.res_partner_1')
        self.currency_usd = self.env.ref('base.USD')
        self.payment_term = self.env.ref('account.account_payment_term_15days')
        self.product = self.env.ref('product.product_product_4')
        self.company = self.env.ref('base.main_company')
        self._create_account_type()

        # we create an invoice
        inv_date = date.today() - timedelta(days=16)
        self.invoice = self.account_invoice_model.create({
            'partner_id':
            self.partner_agrolait.id,
            'reference_type':
            'none',
            'currency_id':
            self.currency_usd.id,
            'name':
            'invoice to customer',
            'payment_term_id':
            self.payment_term.id,
            'account_id':
            self.receivable_account.id,
            'type':
            'out_invoice',
            'date_invoice':
            fields.Date.to_string(inv_date)
        })

        self.account_invoice_line_model.create({
            'product_id':
            self.product.id,
            'quantity':
            1,
            'price_unit':
            100,
            'account_id':
            self.sales_account.id,
            'invoice_id':
            self.invoice.id,
            'name':
            'product that cost 100'
        })
        workflow.trg_validate(self.uid, 'account.invoice', self.invoice.id,
                              'invoice_open', self.cr)
Example #3
0
    def write(self, vals):
        res = super(StockMove, self).write(vals)
        from odoo import workflow
        if vals.get('state') == 'assigned':
            mro_obj = self.env['mro.order']
            order_ids = mro_obj.search([('procurement_group_id', 'in',
                                         [x.group_id.id for x in self])])
            for order_id in order_ids:
                if order_id.test_ready():
                    workflow.trg_validate(self.env.user.id, 'mro.order',
                                          order_id.id, 'parts_ready',
                                          self.env.cr)
        return res


# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
    def action_cancel(self):
        if not len(self.ids):
            return True
        pickings = {}
        for move in self:
            if move.state in ('confirmed', 'waiting', 'assigned', 'draft'):
                if move.picking_id:
                    pickings[move.picking_id.id] = True
        self.write({'state': 'cancel'})
        for pick_id in pickings:
            workflow.trg_validate(self._uid, 'stock.picking', pick_id,
                                  'button_cancel', self._cr)
        ids2 = []
        for res in self.read(['move_dest_id']):
            if res['move_dest_id']:
                ids2.append(res['move_dest_id'][0])


#        for stock_id in self.ids:
            self.trg_trigger()
        return True