콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

I'm working on customized module that added analytic account field in stock.move model and it also add this field into the journal entry but it added it on the debit line. I need to add the analytic field on credit line please, this the code from the module

class StockMove(models.Model):
_inherit = "stock.move"

analytic_account_id = fields.Many2one(
    string="Analytic Account", comodel_name="account.analytic.account",)

def _prepare_account_move_line(
    self, qty, cost, credit_account_id, debit_account_id, description):
    self.ensure_one()
    res = super(StockMove, self)._prepare_account_move_line(
        qty, cost, credit_account_id, debit_account_id, description
    )
    # Add analytic account in debit line
    if not self.analytic_account_id or not res:
        return res

    for num in range(0, 2):
        if (res[num][2]["account_id"]!= self.product_id.categ_id.property_stock_valuation_account_id.id):
            res[num][2].update({"analytic_account_id": self.analytic_account_id.id})

    return res

@api.model
def _prepare_merge_moves_distinct_fields(self):
    fields = super()._prepare_merge_moves_distinct_fields()
    fields.append("analytic_account_id")
    return fields

any help will be appreciated

아바타
취소
관련 게시물 답글 화면 활동
1
9월 17
6048
1
3월 15
6085
0
2월 21
3390
0
1월 25
988
0
5월 24
1344